]> granicus.if.org Git - libevent/commitdiff
Do not make bufferevent_setfd implicitly disable EV_READ and EV_WRITE.
authorNick Mathewson <nickm@torproject.org>
Thu, 24 Dec 2009 22:47:14 +0000 (17:47 -0500)
committerNick Mathewson <nickm@torproject.org>
Mon, 28 Dec 2009 21:59:07 +0000 (16:59 -0500)
This obviates the need for BEV_SUSPEND_CONNECTING, and good riddance.

bufferevent-internal.h
bufferevent_openssl.c
bufferevent_sock.c

index 220cdeb72ef69fa768826dddb4a4a1c777b31821..9594784a2a32d3196ab61410060ba245710650b0 100644 (file)
@@ -53,9 +53,6 @@ extern "C" {
 #define BEV_SUSPEND_BW 0x02
 /* On a base bufferevent: when we have emptied the group's bandwidth bucket. */
 #define BEV_SUSPEND_BW_GROUP 0x04
-/* On a socket bufferevent: we aren't going to try reading until the
- * connect operation is done. */
-#define BEV_SUSPEND_CONNECTING 0x08
 
 struct bufferevent_rate_limit_group {
        /** List of all members in the group */
index e2cb28b123cbc3670f45b283f0688f8fff49adf5..3ec56f744079c1916010e29a6df86ce037ce0386 100644 (file)
@@ -678,6 +678,7 @@ consider_reading(struct bufferevent_openssl *bev_ssl)
        if (bev_ssl->write_blocked_on_read)
                return;
        while ((bev_ssl->bev.bev.enabled & EV_READ) &&
+           (! bev_ssl->bev.read_suspended) &&
            (! wm->high || evbuffer_get_length(input) < wm->high)) {
                int n_to_read =
                    wm->high ? wm->high - evbuffer_get_length(input)
@@ -708,6 +709,7 @@ consider_writing(struct bufferevent_openssl *bev_ssl)
                wm = &bev_ssl->underlying->wm_write;
        }
        while ((bev_ssl->bev.bev.enabled & EV_WRITE) &&
+           (! bev_ssl->bev.write_suspended) &&
            evbuffer_get_length(output) &&
            (!target || (! wm->high || evbuffer_get_length(target) < wm->high))) {
                int n_to_write;
index f53689eefc99dc4b94549e71c2a47106c6121bfb..d1b5792a6f9916db69ba1f5ce81bbd2fe1e951dc 100644 (file)
@@ -222,7 +222,6 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
                        goto done;
                } else {
                        connected = 1;
-                       bufferevent_unsuspend_read(bufev, BEV_SUSPEND_CONNECTING);
 #ifdef WIN32
                        if (BEV_IS_ASYNC(bufev)) {
                                event_del(&bufev->ev_write);
@@ -408,11 +407,7 @@ freesock:
        if (ownfd)
                EVUTIL_CLOSESOCKET(fd);
        /* do something about the error? */
-
 done:
-       if (result == 0)
-               bufferevent_suspend_read(bev, BEV_SUSPEND_CONNECTING);
-
        _bufferevent_decref_and_unlock(bev);
        return result;
 }
@@ -575,6 +570,10 @@ be_socket_setfd(struct bufferevent *bufev, evutil_socket_t fd)
            EV_READ|EV_PERSIST, bufferevent_readcb, bufev);
        event_assign(&bufev->ev_write, bufev->ev_base, fd,
            EV_WRITE|EV_PERSIST, bufferevent_writecb, bufev);
+
+       if (fd >= 0)
+               bufferevent_enable(bufev, bufev->enabled);
+
        BEV_UNLOCK(bufev);
 }