Welcome! Log In Create A New Profile

Advanced

Why does ngx_epoll_del_event use EPOLL_CTL_MOD

Qiying Wang
October 28, 2019 03:26AM
Hello!

ngx_epoll_del_event is a function to delete an event. Deleting an event
means unregister the file descriptor from epoll therefore it would not be
triggered unless being added again. But EPOLL_CTL_MOD won't remove the
event as far as I know. It seems the event would be triggered in the next
processing loop. So why use EPOLL_CTL_MOD here rather than just
EPOLL_CTL_DEL?

The source code is located in `src/event/modules/ngx_epoll_module.c`

static ngx_int_t
ngx_epoll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
{
// ......

if (e->active) {
op = EPOLL_CTL_MOD;
ee.events = prev | (uint32_t) flags;
ee.data.ptr = (void *) ((uintptr_t) c | ev->instance);

} else {
op = EPOLL_CTL_DEL;
ee.events = 0;
ee.data.ptr = NULL;
}

ngx_log_debug3(NGX_LOG_DEBUG_EVENT, ev->log, 0,
"epoll del event: fd:%d op:%d ev:%08XD",
c->fd, op, ee.events);

if (epoll_ctl(ep, op, c->fd, &ee) == -1) {
ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_errno,
"epoll_ctl(%d, %d) failed", op, c->fd);
return NGX_ERROR;
}

ev->active = 0;

return NGX_OK;
}
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Why does ngx_epoll_del_event use EPOLL_CTL_MOD

Qiying Wang 606 October 28, 2019 03:26AM

Re: Why does ngx_epoll_del_event use EPOLL_CTL_MOD

tokers 360 October 28, 2019 03:56AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 234
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready