We consider volume-preserving flows (Φ f t ) t∈R on S × R, where S is a compact connected surface of genus g ≥ 2 and (Φwhere (φ t ) t∈R is a locally Hamiltonian flow of hyperbolic periodic type on S and f is a smooth real valued function on S. We investigate ergodic properties of these infinite measure-preserving flows and prove that if f belongs to a space of finite codimension in C 2+ (S), then the following dynamical dichotomy holds: if there is a fixed point of (φ t ) t∈R on which f does not vanish, then (Φ f t ) t∈R is ergodic, otherwise, if f vanishes on all fixed points, it is reducible, i.e. isomorphic to the trivial extension (Φ 0 t ) t∈R . The proof of this result exploits the reduction of (Φ f t ) t∈R to a skew product automorphism over an interval exchange transformation of periodic type. If there is a fixed point of (φ t ) t∈R on which f does not vanish, the reduction yields cocycles with symmetric logarithmic singularities, for which we prove ergodicity.