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

Re: [Libevent-users] Using event_active() for partial reading with bufferevents




On Tue, Nov 6, 2012 at 12:29 AM, Himanshu S <mail2himanshu@xxxxxxxxx> wrote:
Hi,
   I am using bufferevent_* APIs for my application to read/write data to TCP stream. When the data arrives, the read callback happens, I want to read partial data (at times), and then be able to post an event back so that the event is queued up and read callback is called again. I thought event_active() gives this functionality but apparently its not. I am using event_active with following parameters,

event_active(&bev->ev_read, EV_READ, 1);

That is _really_ not supported. Anything that touches bufferevent internals is going to get you potentially unpredicted results.  

Right now the best way to do what you have in mind is to consider *why* you only want to read partial data and then read again after the next event loop -- there's usually a better way to do whatever you're trying to achieve.  But if there isn't, and you want to make sure your code works with future versions of Libevent, your best bet is either to add a feature like this in Libevent 2.1, or to create a separate event whose callback will also run the bufferevent's callback, and activate that one.

hth,
-- 
Nick