[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] event_base_dispatch returning -1 - help debugging



On Tue, Jun 12, 2012 at 3:09 PM, Dave Hart <davehart@xxxxxxxxx> wrote:
> On Tue, Jun 12, 2012 at 5:06 PM, Julian Bui <julianbui@xxxxxxxxx> 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.

Actually I think it's a C error.  Check out the documentation for
event_pending():
/*
  @return true if the event is pending on any of the events in 'what', (that
  is to say, it has been added), or 0 if the event is not added.
*/

Note that it says "@return true"; it doesn't say "@return 1".  In C,
any nonzero integer is true.

The documentation should probably be more clear that what it actually
returns its a bitfield of which flags are set, anded with its "events"
argument.

yrs,
-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.