Skip to content

Commit 3595de5

Browse files
committed
Small fix in epoll plugin: actually check that EPOLLERR is not set in recved events mask.
1 parent b7a7c58 commit 3595de5

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

Lib/modules.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ static inline module_ret_code loop_quit(ctx_t *c, const uint8_t quit_code) {
133133
}
134134

135135
static int recv_events(ctx_t *c, int timeout) {
136+
int real_recv = 0;
136137
int nfds = poll_wait(c->fd, c->max_events, c->pevents, timeout);
137138
for (int i = 0; i < nfds; i++) {
138139
fd_priv_t *p = poll_recv(i, c->pevents);
@@ -166,25 +167,20 @@ static int recv_events(ctx_t *c, int timeout) {
166167
MODULE_DEBUG("PoisonPilling '%s'.\n", mod->name);
167168
stop(mod, true);
168169
}
169-
} else {
170-
/* Forward error to below handling code */
171-
errno = ENXIO;
172-
nfds = -1;
170+
real_recv++;
173171
}
174172
}
175173

176-
if (nfds > 0) {
174+
if (real_recv > 0) {
177175
evaluate_new_state(c);
178176
} else if (nfds < 0) {
179177
/* Quit and return < 0 only for real errors */
180178
if (errno != EINTR && errno != EAGAIN) {
181179
fprintf(stderr, "Ctx '%s' loop error: %s.\n", c->name, strerror(errno));
182180
loop_quit(c, errno);
183-
} else {
184-
nfds = 0;
185181
}
186182
}
187-
return nfds;
183+
return real_recv;
188184
}
189185

190186
/** Public API **/

Lib/poll_plugins/epoll_priv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ int poll_wait(const int fd, const int max_events, void *pevents, const int timeo
3636

3737
fd_priv_t *poll_recv(const int idx, void *pevents) {
3838
struct epoll_event *pev = (struct epoll_event *) pevents;
39+
if (pev[idx].events & EPOLLERR) {
40+
return NULL;
41+
}
3942
return (fd_priv_t *)pev[idx].data.ptr;
4043
}
4144

0 commit comments

Comments
 (0)