diff options
author | Haibo Huang <hhb@google.com> | 2020-07-14 18:31:56 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-07-14 18:31:56 +0000 |
commit | 884d7a39094e590c9dc58f865b068f40694c6a49 (patch) | |
tree | 53915fc3eafdda183ab94c84e85ad7d7107afc6a /poll.c | |
parent | c4d7c4bdab4c5587b42073d60fb6aca6e335d76e (diff) | |
parent | 023ea039b9fada42e0cbbefcd75858a855a6130a (diff) | |
download | libevent-884d7a39094e590c9dc58f865b068f40694c6a49.tar.gz |
Upgrade libevent to release-2.1.12-stable am: f0077b80a0 am: 023ea039b9
Original change: https://android-review.googlesource.com/c/platform/external/libevent/+/1360893
Change-Id: Iee716ec96a55737a04463c7b84c929c2e6418c54
Diffstat (limited to 'poll.c')
-rw-r--r-- | poll.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -53,6 +53,17 @@ #include "evthread-internal.h" #include "time-internal.h" +/* Since Linux 2.6.17, poll is able to report about peer half-closed connection + using special POLLRDHUP flag on a read event. +*/ +#if !defined(POLLRDHUP) +#define POLLRDHUP 0 +#define EARLY_CLOSE_IF_HAVE_RDHUP 0 +#else +#define EARLY_CLOSE_IF_HAVE_RDHUP EV_FEATURE_EARLY_CLOSE +#endif + + struct pollidx { int idxplus1; }; @@ -79,8 +90,8 @@ const struct eventop pollops = { poll_del, poll_dispatch, poll_dealloc, - 0, /* doesn't need_reinit */ - EV_FEATURE_FDS, + 1, /* need_reinit */ + EV_FEATURE_FDS|EARLY_CLOSE_IF_HAVE_RDHUP, sizeof(struct pollidx), }; @@ -204,6 +215,8 @@ poll_dispatch(struct event_base *base, struct timeval *tv) res |= EV_READ; if (what & POLLOUT) res |= EV_WRITE; + if (what & POLLRDHUP) + res |= EV_CLOSED; if (res == 0) continue; @@ -222,7 +235,7 @@ poll_add(struct event_base *base, int fd, short old, short events, void *idx_) int i; EVUTIL_ASSERT((events & EV_SIGNAL) == 0); - if (!(events & (EV_READ|EV_WRITE))) + if (!(events & (EV_READ|EV_WRITE|EV_CLOSED))) return (0); poll_check_ok(pop); @@ -265,6 +278,8 @@ poll_add(struct event_base *base, int fd, short old, short events, void *idx_) pfd->events |= POLLOUT; if (events & EV_READ) pfd->events |= POLLIN; + if (events & EV_CLOSED) + pfd->events |= POLLRDHUP; poll_check_ok(pop); return (0); @@ -283,7 +298,7 @@ poll_del(struct event_base *base, int fd, short old, short events, void *idx_) int i; EVUTIL_ASSERT((events & EV_SIGNAL) == 0); - if (!(events & (EV_READ|EV_WRITE))) + if (!(events & (EV_READ|EV_WRITE|EV_CLOSED))) return (0); poll_check_ok(pop); @@ -297,6 +312,8 @@ poll_del(struct event_base *base, int fd, short old, short events, void *idx_) pfd->events &= ~POLLIN; if (events & EV_WRITE) pfd->events &= ~POLLOUT; + if (events & EV_CLOSED) + pfd->events &= ~POLLRDHUP; poll_check_ok(pop); if (pfd->events) /* Another event cares about that fd. */ |