diff --git a/ChangeLog b/ChangeLog index ad9665c5..cb4900af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -16,6 +16,7 @@ Changes in 2.0.3-alpha: o Have bufferevent_socket_connect() with no arguments put a bufferevent into connecting mode. o Support sendfile on Solaris: patch from Caitlin Mercer. o New functions to explicitly reference a socket used by an evhttp object. Patches from David Reiss. + o When we send a BEV_EVENT_CONNECTED to indicate connected status, we no longer invoke the write callback as well unless we actually wrote data too. Changes in 2.0.2-alpha: diff --git a/bufferevent_sock.c b/bufferevent_sock.c index 3f32b1db..f78fc094 100644 --- a/bufferevent_sock.c +++ b/bufferevent_sock.c @@ -183,6 +183,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg) EVUTIL_UPCAST(bufev, struct bufferevent_private, bev); int res = 0; short what = BEV_EVENT_WRITING; + int connected = 0; _bufferevent_incref_and_lock(bufev); @@ -192,6 +193,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg) } if (bufev_p->connecting) { bufev_p->connecting = 0; + connected = 1; _bufferevent_run_eventcb(bufev, BEV_EVENT_CONNECTED); if (!(bufev->enabled & EV_WRITE)) { event_del(&bufev->ev_write); @@ -226,7 +228,7 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg) * Invoke the user callback if our buffer is drained or below the * low watermark. */ - if (bufev->writecb != NULL && + if (bufev->writecb != NULL && (res || !connected) && evbuffer_get_length(bufev->output) <= bufev->wm_write.low) _bufferevent_run_writecb(bufev);