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

[Libevent-users] libevent & evbuffer_add_reference



Hi Nick,

a short one about events: I was assuming that

    evbuffer_add_reference(evb, tx.buffer.ptr, tx.buffer.slen, onsent, ref);

would call the "onsent" callback asynchroneously (having a bufferevent with the BEV_OPT_DEFER_CALLBACKS option set on instantiation).

Apparently, this is not right, as the onsent-callback appears instantly (as long as the bev is not on its high watermark).

My idea was to use that kind of callback to fetch the next piece of data to send, but in the current implementation, this leads to a recursion (on the stack).

So my question: is that intended behaviour? If yes, should I queue an event (e.g. timer with timeval = { 0, 0 }) to unwind the stack before actually calling my onsent handler?

Any tips appreciated!
  Roman