libevent code