Thanks for your response!
I have an overly simplified, single threaded SSL test server (based on examples found in the libevent documentation) that has the following callback funcs:
ssl_readcb(struct bufferevent * bev, void * arg) struct evbuffer *in = bufferevent_get_input(bev); printf("Received %zu bytes\n", evbuffer_get_length(in)); printf("----- data ----\n"); printf("%.*s\n", (int)evbuffer_get_length(in), evbuffer_pullup(in, -1)); bufferevent_write_buffer(bev, in); printf("::: wrote to the buffer\n"); printf("::: done sleeping\n"); ssl_writecb(struct bufferevent * bev, void * arg)
I connect to the server with the following:
openssl s_client -connect 0:9999
With the code as written above, because of the 'sleep(2)', I would expect the following in a fully async model:
- type 'hello' on the client
- see the server receive 'hello' by printing the '---- data ----', etc lines
- see the server print '::: wrote to the buffer'
- 2 seconds to elapse
- see the server print '::: done sleeping'
- see the client receive the echo 'hello'
- server prints 'writecb: in'
Instead, this happens:
- type 'hello' on the client
- see the server receive 'hello' by printing the '---- data ----', etc lines
- see the server print '::: wrote to the buffer'
- see the client receive the echo 'hello'
- 2 seconds elapse
- see the server print '::: done sleeping'
- server prints 'writecb: in'
The write is being sent to the client immediately from within the readcb. Please let me know if I'm doing something wrong, but I'm not sure how to interpret this behavior other than there's at least one synchronous write happening from within the read handler?
Thanks!
- scott
On Thu, Jul 18, 2013 at 04:09:20AM -0600, J. Scott Dorr wrote:
So, when using bufferevent_write/write_buffer, is there a way to enforce asynchronicity?
Bufferevents *are* async. How are you determining it is not?
|