You're right, Dave, about the print statements.  I accidentally pasted my
code and then modified what was printed out.  The else should read: else {
cout << "event is not pending" << endl; } and this line of code always gets
executed, despite it still getting triggered on incoming connection.

I'll work on getting a more basic piece of code that I can put on the
internet. I just difficult to release a complete piece of code with this
being a commercial product.


On Tue, Jun 12, 2012 at 12:09 PM, Dave Hart <daveh...@gmail.com> wrote:

> 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.
>

Reply via email to