canal_lock, ported from the Gtk+ version