[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [Libevent-users] immediately flushing bufferevents
On Mon, Oct 03, 2011 at 11:59:58AM +0200, Micha? Kr?l wrote:
> Hi,
>
> I'm writing distributed application using the newest version of libevent
> (2.0.14). To read and write from/to sockets I use recv,send statement and it
> works perfectly. Now I want to use SSL support provided by libevent. In
> order to do it I wanted to use bufferevents. The problem is, when I change
> send statement to bufferevent_write, packets are not sent immediately, but
> seems to wait for more data to send, and I need to send them immediately
> (bufferevent_write returns without error). I didn't change watermarks as I
> think default behaviour shall be to send data immediately.
>
> I tried using bufferevent_flush, but it didn't help.
>
Flushing on openssl bufferevents isn't supported right now that I can
recall. But there are some things that have to go on in the background
for any ssl connection that may take a little time for something to be
sent. Are you using BEV_OPT_DEFER_CALLBACKS? If so that could be your
culprit.
Also your operating system may be buffering the data itself. If you are
sending small packets, nagle's algorithm may be waiting for MSS to be
filled before sending; try disabling this feature via setsockopt and
just to make sure this is not the case.
> So here I my questions - is it possible to force bufferevent to send data
> immediately?
>
Without DEFER_CALLBACKS or watermaks it should.
> If I understand well (I'm new to SSL) it's impossible to create event by
> bufferevent_new_ssl_socket and then using unix send(bufferevent_getfd())
> statement?
>
Correct, data has to be encrypted, so sending data to the raw socket
wrapped around SSL will result in the session being terminated.
> PS. I know it may seem like bug in my code during switching from events to
> bufferevents, but now I only changed my bufferevent_write statements to
> send(bufferevent_getfd()) statements and it works perfectly again....
Sounds fishy :)
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.