[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] deferred callbacks and evbuffer cleanup_cb
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] deferred callbacks and evbuffer cleanup_cb
- From: Jan Heylen <heyleke@xxxxxxxxx>
- Date: Sun, 20 Mar 2016 10:58:34 +0100
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Sun, 20 Mar 2016 05:58:38 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=lMjt7Mw1h7A/IP3trF65ygqnjuZEQPewdD5WLr3xPAc=; b=OFiY/Xhh0oRg4HCKLa7WQQU/aVvlTZAJkfk6G22Ln7/MwdDdjk4CktMaKi1ISeGndi HLVfzkBneTuqtPzpUVuGHFirgmrl23c9MJmrYHAMiEc37Sndgb8JtcsYePkHLQxYCxn2 iPtb3Fzza0kPNBh0fbEI367dMfNVXm27gEBiV4+FmS8UkXgnNG8S4tjdWxGbqgiXfZYN S8jrRWkA54kOVj3RUrbkbG0nbP0OZVIgSi8T1zGMLZD+385M9kF3+x1wMHGmm7yralch Vm/a0ZHpVzQwlHwW4Gk3C4bGW+8NjpqJ5w0erIZMgsv7tafNP/GwtIpAiLuN1ic7+mPz NnJg==
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hi,
I'm trying to use evbuffers, cleanup_cb, and the deferred callbacks.
some background:
* using (tcp) sockets
* sending data over the socket: in first place try to write
(evbuffer_write), if you get 'wouldblock' postpone the write by using
bufferevent_write_buffer. Main reason is we don't need to keep the
user's data in most cases and the dat is send immediatly.
* after sending data, a 'send cb' should be called to the user who
wanted to send something.
Now, when looking at the best way to get the cleanup happening (and a
mechanism to let the user know his data is send), I was looking at
both evbuffer callbacks and the evbuffer cleanup_cb.
I'm thinking on using the cleanup_cb, as it is only called when the
chain, the actual data, gets freed, so I can be sure the data is out.
With evbuffer callbacks, the original evbuffer gets drained upon call
to bufferevent_write_buffer already, and not when the data itself is
really 'out', so that means, I have to make a distinction.
However, If I look at the code, these cleanup_cbs are not and cannot
be 'deferred'. So in the first place, when using evbuffer_write, the
cleanup_cb will happen on the stack, and so also my 'data is send'
callback, would happen on stack (and so cb will happen before the
sending data function returns).
Questions:
* thinking about the 2 different paths on getting data out,
(evbuffer_write and postponed via bufferevent_write_buffer), what
would be the best mechanism to get the 'all data is out' cb mechanism
working for them both?
* Is it a design choice to not defer the cleanup_cb, or would it make
sense to add it?
kind regards,
Jan Heylen
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.