[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] bufferevents and write signalling
- To: libevent-users@xxxxxxxxxxxxx
- Subject: Re: [Libevent-users] bufferevents and write signalling
- From: Nick Mathewson <nickm@xxxxxxxxxxxxx>
- Date: Thu, 5 Aug 2010 14:09:50 -0400
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Thu, 05 Aug 2010 14:10:00 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type:content-transfer-encoding; bh=9dcxMFxmP4rISpbGZh5N4IhKTl9c8NHzBpidBB5Kg74=; b=E1YA/QHUPy2dN+J9jL/4JbEhvxQugRtA8Pk8RjZStn3RelWbT4L8DZ371djIlPDBjz 0bRfzzFWIk/KQm7gVIbqprVJ6YQOzgoGHYlKSHNc3O7W3O717zA06bStj95KgBzaFJci mQ5VmHwlxvg/NYzO3WXZrsfr3uLbsDZtHDTVo=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=J3AdQA/AllnNJcf4nSD7Z1KkHsoBmVIq+FtLickHq4n8KpQP63htfx57fXtT2A6PjN E1I03zMEh2SZ9nMfwYqX8x4dSG79oMTmVwuxCq3ReX4sxz59Dl9PODkVoN7iESFHuu+j reBzDz31SCAfYUgevmv4WRBC7HA+UEiLsnCOI=
- In-reply-to: <20100805181321.GA29941@xxxxxxxxxx>
- References: <20100805181321.GA29941@xxxxxxxxxx>
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
On Thu, Aug 5, 2010 at 2:13 PM, Mark Ellzey <mthomas@xxxxxxxxxx> wrote:
>
> This is an odd question that hopefully someone can help me out with. I
> have a function right now that looks a bit like this:
>
> void
> read_data(struct bufferevent *bev, void *args) {
> evbuffer *data;
>
> data = bufferevent_get_input(bev)
>
> if (evbuffer_get_length(data) < some_size) {
> /* waiting for some specific amount of data */
> return;
>
> .... process data here ....
>
> evbuffer_drain(data, some_size);
>
> if (evbuffer_get_length(data)) {
> return read_data(bev, args);
> }
> }
>
> If more data is present at the time it has finished reading one block of
> data it was interested in, if you were to return, you never get notified
> unless something was added.
Right. The read callback is invoked when more data *arrives,* not
whenever there is data.
If you want it to handle all the data, why not just use a loop:
while (evbuffer_get_length(data) >= some_size) {
/* ... */
}
That way you avoid the arbitrary recursion.
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.