Fixed CE with old libevent

This commit is contained in:
vvaltman 2014-09-21 13:18:12 +04:00
parent 4a773fe6e2
commit 0200b5144f
2 changed files with 4 additions and 3 deletions

View File

@ -60,6 +60,7 @@ struct in_ev {
int in_buf_pos; int in_buf_pos;
int refcnt; int refcnt;
int error; int error;
int fd;
}; };

6
loop.c
View File

@ -629,9 +629,8 @@ static void event_incoming (struct bufferevent *bev, short what, void *_arg) {
struct in_ev *ev = _arg; struct in_ev *ev = _arg;
if (what & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) { if (what & (BEV_EVENT_EOF | BEV_EVENT_ERROR)) {
vlogprintf (E_WARNING, "Closing incoming connection\n"); vlogprintf (E_WARNING, "Closing incoming connection\n");
int fd = bufferevent_getfd (bev); assert (ev->fd >= 0);
assert (fd >= 0); close (ev->fd);
close (fd);
bufferevent_free (bev); bufferevent_free (bev);
ev->bev = 0; ev->bev = 0;
ev->refcnt --; ev->refcnt --;
@ -650,6 +649,7 @@ static void accept_incoming (evutil_socket_t efd, short what, void *arg) {
e->refcnt = 1; e->refcnt = 1;
e->in_buf_pos = 0; e->in_buf_pos = 0;
e->error = 0; e->error = 0;
e->fd = fd;
bufferevent_setcb (bev, read_incoming, 0, event_incoming, e); bufferevent_setcb (bev, read_incoming, 0, event_incoming, e);
bufferevent_enable(bev, EV_READ|EV_WRITE); bufferevent_enable(bev, EV_READ|EV_WRITE);
} }