On Tue, Jun 12, 2012 at 5:06 PM, Julian Bui <julian...@gmail.com> wrote: > Oh, one more thing. I would really like to verify that there is indeed an > event still pending - because I can at least restart the dispatch loop if > there is an event pending. But I have not been able to correctly use > event_pending for some reason. My code is below
You have incomplete pseudocode below. > and it always prints "event is not pending" regardless of My reading has it always printing "event is still pending" regardless of anything. > whether or not the dispatch loop is running. > The code sets up a persistent event that will handle every incoming > connection to my server. I would expect that at some point it would print > out that the event is pending...because like I said, this code DOES work > most of the time, and if it's not pending I have no idea why the handlers > would even still be triggered. > > struct event* my_event = event_new(s_event_base, server_socket, EV_READ | > EV_PERSIST, &TileSocketServer::onAccept, (void*) client); > > if(my_event != NULL) > { > int add_err = event_add(my_event, NULL); > > if(add_err != 0) > cout << "add_err:" << add_err << endl; > > int is_evt_pending = event_pending(my_event, EV_READ | EV_PERSIST, > NULL); > if(is_evt_pending == 1) > { > cout << "event is still pending" << endl; > } > else > { > cout << "event is still pending" << endl; > } I suggest providing a complete, freestanding example that others can actually compile rather than simply speculate about. Cheers, Dave Hart *********************************************************************** To unsubscribe, send an e-mail to majord...@freehaven.net with unsubscribe libevent-users in the body.