libevent: protect callbacks for compatibility with the light FFI