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

Re: [Libevent-users] event_base_dispatch not returning

On Thu, May 22, 2014 at 2:26 PM, Stephen Andrew <sjahf7@xxxxxxx> wrote:
> I'm trying to get an event loop running, using event_base_dispatch. However,
> the function fails to return (blocks)
> I had it running, until I changed something in another source file - which
> might be a part of the callback structure.
> Here's (sort of) what my code looks like:
> ev1 = event_new(base, fd, EV_READ|EV_PERSIST, grab_packet, some_struct)
> event_base_dispatch(base); //this is where it gets stuck

So, assuming that you also do an event_add(ev1, NULL), this code will
ordinarily stay inside event_base_dispatch until there are no more
pending events (that is, until somebody calls event_del(ev1), or until
you call event_base_loopexit, or until you call
event_base_loopbreak().  The question to answer may be, which of these
cases was making it exit event_base_dispatch() before?

If that doesn't shed light on the problem, I'd try using a debugger to
see whether your program is getting stuck in event_base_dispatch, and
if so, which of the conditions that should be making
event_base_dispatch exit isn't happening.
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.