mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Do not ignore bufferevent_enable(EV_READ) before bufferevent_connect().
Previously, we weren't remembering that we wanted to re-add the read event once the connect was finished. Now we are.
This commit is contained in:
parent
390e056152
commit
4a5b53432b
@ -50,6 +50,9 @@ extern "C" {
|
||||
#define BEV_SUSPEND_WM 0x01
|
||||
/* On a base bufferevent: when we have used up our bandwidth buckets. */
|
||||
#define BEV_SUSPEND_BW 0x02
|
||||
/* On a socket bufferevent: we aren't going to try reading until the
|
||||
* connect operation is done. */
|
||||
#define BEV_SUSPEND_CONNECTING 0x04
|
||||
|
||||
struct token_bucket {
|
||||
uint32_t limit;
|
||||
|
@ -212,6 +212,7 @@ 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);
|
||||
@ -223,7 +224,8 @@ bufferevent_writecb(evutil_socket_t fd, short event, void *arg)
|
||||
#endif
|
||||
_bufferevent_run_eventcb(bufev,
|
||||
BEV_EVENT_CONNECTED);
|
||||
if (!(bufev->enabled & EV_WRITE)) {
|
||||
if (!(bufev->enabled & EV_WRITE) ||
|
||||
bufev_p->write_suspended) {
|
||||
event_del(&bufev->ev_write);
|
||||
goto done;
|
||||
}
|
||||
@ -391,6 +393,9 @@ freesock:
|
||||
/* do something about the error? */
|
||||
|
||||
done:
|
||||
if (result == 0)
|
||||
bufferevent_suspend_read(bev, BEV_SUSPEND_CONNECTING);
|
||||
|
||||
_bufferevent_decref_and_unlock(bev);
|
||||
return result;
|
||||
}
|
||||
|
@ -491,12 +491,12 @@ test_bufferevent_connect(void *arg)
|
||||
bufferevent_setcb(bev1, NULL, NULL, reader_eventcb, data->base);
|
||||
bufferevent_setcb(bev2, NULL, NULL, reader_eventcb, data->base);
|
||||
|
||||
tt_want(!bufferevent_socket_connect(bev1, sa, sizeof(localhost)));
|
||||
tt_want(!bufferevent_socket_connect(bev2, sa, sizeof(localhost)));
|
||||
|
||||
bufferevent_enable(bev1, EV_READ);
|
||||
bufferevent_enable(bev2, EV_READ);
|
||||
|
||||
tt_want(!bufferevent_socket_connect(bev1, sa, sizeof(localhost)));
|
||||
tt_want(!bufferevent_socket_connect(bev2, sa, sizeof(localhost)));
|
||||
|
||||
#ifdef WIN32
|
||||
/* FIXME this is to get IOCP to work. it shouldn't be required. */
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user