diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-08-18 11:41:55 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-08-18 11:41:55 -0400 |
commit | 495c227f59093543dcc8f72e699e146ec9f82d10 (patch) | |
tree | debceb39a54f67fc03e08caffedafcf277cb0e74 /bufferevent_async.c | |
parent | 643922e9079c2d2b5dd534cda8ca94f43025889c (diff) | |
download | libevent-495c227f59093543dcc8f72e699e146ec9f82d10.tar.gz |
IOCP: don't launch reads or writes on an unconnected socket
Diffstat (limited to 'bufferevent_async.c')
-rw-r--r-- | bufferevent_async.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/bufferevent_async.c b/bufferevent_async.c index 76a16162..87ba404c 100644 --- a/bufferevent_async.c +++ b/bufferevent_async.c @@ -188,7 +188,7 @@ bev_async_consider_writing(struct bufferevent_async *beva) /* Don't write if there's a write in progress, or we do not * want to write, or when there's nothing left to write. */ - if (beva->write_in_progress) + if (beva->write_in_progress || beva->bev.connecting) return; if (!beva->ok || !(bev->enabled&EV_WRITE) || !evbuffer_get_length(bev->output)) { @@ -234,7 +234,7 @@ bev_async_consider_reading(struct bufferevent_async *beva) /* Don't read if there is a read in progress, or we do not * want to read. */ - if (beva->read_in_progress) + if (beva->read_in_progress || beva->bev.connecting) return; if (!beva->ok || !(bev->enabled&EV_READ)) { bev_async_del_read(beva); @@ -324,7 +324,11 @@ be_async_enable(struct bufferevent *buf, short what) if (!bev_async->ok) return -1; - /* NOTE: This interferes with non-blocking connect */ + if (bev_async->bev.connecting) { + /* Don't launch anything during connection attempts. */ + return 0; + } + if (what & EV_READ) BEV_RESET_GENERIC_READ_TIMEOUT(buf); if (what & EV_WRITE) |