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

Re: [Libevent-users] segfault issue



On Thu, Mar 22, 2012 at 08:18:21PM -0500, Mark Ellzey wrote:
> On Thu, Mar 22, 2012 at 07:11:01PM -0300, William Lima wrote:
> > Hi!
> > 
> > I'm using bufferevent in my proxy project and I have a bug. The entire
> > program is single-thread, but apparently the error callback can be called
> > while something is still running (ie. a parser) into server/client read
> > callbacks, causing a segmentation fault, since the error callback destroy
> > the Connection class.
> > Is it the expected behavior? Should I add a *state* to check when a
> > callback is running and not delete on error callback directly?
> > 
> > The related code is listed below (server_error_cb, server_read_cb functions
> > are similar, but not listed):
> > 
> 
> I would suggest setting BEV_OPT_DEFER_CALLBACKS when creating your
> bufferevents if you're using it like this.
> 

Just as a quick informational follow-up here, when a bufferevent is
deferred, all of the events you trigger will not be executed until the
code has dropped back into the main event loop. This means the event
execution is ordered, so that (in this case) your error callback doesn't 
get called before a write has finished.  

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