mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-08 11:53:00 -04:00
Do not make bufferevent_setfd implicitly disable EV_READ and EV_WRITE.
This obviates the need for BEV_SUSPEND_CONNECTING, and good riddance.
This commit is contained in:
parent
f0c0124e60
commit
82743794d3
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user