From e3be71ea46423722c2e4c6de931631d75fc57efd Mon Sep 17 00:00:00 2001 From: ruti <> Date: Fri, 10 May 2024 02:30:17 +0300 Subject: [PATCH] set POLLRDHUP flag --- conev.c | 11 ++++++----- proxy.c | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/conev.c b/conev.c index 2a23301..c046d4e 100644 --- a/conev.c +++ b/conev.c @@ -65,7 +65,7 @@ struct eval *add_event(struct poolhd *pool, enum eid type, struct pollfd *pfd = &(pool->pevents[pool->count]); pfd->fd = fd; - pfd->events = e; + pfd->events = POLLRDHUP | e; pfd->revents = 0; #endif @@ -76,12 +76,13 @@ struct eval *add_event(struct poolhd *pool, enum eid type, void del_event(struct poolhd *pool, struct eval *val) { - assert(val && ((val->fd > 0 && val->mod_iter < pool->iters) || - val->mod_iter == pool->iters)); + assert(val->fd >= -1 && val->mod_iter <= pool->iters); if (val->fd == -1) { return; } - + #ifdef NOEPOLL + assert(val->fd == pool->pevents[val->index].fd); + #endif if (val->buff.data) { assert(val->buff.size); free(val->buff.data); @@ -211,7 +212,7 @@ struct eval *next_event(struct poolhd *pool, int *offs, int *typel) int mod_etype(struct poolhd *pool, struct eval *val, int type) { assert(val->index >= 0 && val->index < pool->count); - pool->pevents[val->index].events = type; + pool->pevents[val->index].events = POLLRDHUP | type; return 0; } #endif diff --git a/proxy.c b/proxy.c index f42932d..5e252fe 100644 --- a/proxy.c +++ b/proxy.c @@ -540,7 +540,7 @@ int on_tunnel(struct poolhd *pool, struct eval *val, ssize_t n = 0; struct eval *pair = val->pair; - if (pair->buff.size && out) { + if (pair->buff.data && out) { pair = val; val = val->pair;