[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] Ability to shutdown() socket with bufferevents?
On Tue, Jul 27, 2010 at 2:42 PM, Corey Stup <coreystup@xxxxxxxxx> wrote:
>> Right now there's no way to make a bufferevent call shutdown() itself,
>> but what if you have a write handler on the client bufferevent just
>> call shutdown() manually on the fd to send a FIN when the write buffer
>> is empty? You can get the fd with bufferevent_get_fd().
> How can I check to see if the write buffer is empty? Obviously I'd
> only want to indicate a shutdown() after all my data had been
> processed *and* the buffer is empty.
>
> Inside my write callback, when I call
> struct evbuffer *output = bufferevent_get_output(bev);
> len=evbuffer_get_length(output);
>
> I always get a return length of 0. (I also tried to check the input
> buffer, but its 0 as well). I assumed it would indicate how much
> data was left in the backing evbuffer that hadn't been written to the
> O/S socket buffers.
Yes, that's correct. If
bufferevent_get_length(bufferevent_get_output(bev)) is 0, then all the
data has been written to the TCP stack (with writev or write or
sendfile or whatever was appropriate).
> In that case I'd want to indicate my shutdown
> after I had written all data to the backing evbuffer *and* the
> evbuffers were empty. Am I missing something obvious?
I don't think so.
> Will the flush() sequence I mentioned before be what I'd want to use
> once its implemented?
I'm not sure. Right now, the behavior of flush() on socket
bufferevents is not only unimplemented, but also unspecified. The
behavior you mentioned before is one reasonable thing for it to do, I
think.
> Any timeline if thats the case? (2.1 I assume
> since 2.0 features are locked).
2.1 or later. Right now I don't believe anybody has committed to any
particular list of features for 2.1, and I don't think we even have a
timeline or list of planned stuff for 2.1. It'd be nice to have one.
Of course, if somebody were to commit to write a good flush
implementation for socket bufferevents, that would improve the odds of
it going into 2.1 immensely. ;)
peace,
--
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.