# HG changeset patch # User Valentin Bartenev # Date 1427480360 -10800 # Node ID 953ef81705e1e2d735e956e5fc6406a862e29419 # Parent 3d4730eada9ce03e9247fea0d32068dcecb57a54 Events: fixed possible crash on start or reload. The main thread could wake up and start processing the notify event before the handler was set. diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c --- a/src/event/modules/ngx_epoll_module.c +++ b/src/event/modules/ngx_epoll_module.c @@ -683,14 +683,14 @@ ngx_epoll_notify(ngx_event_handler_pt ha { static uint64_t inc = 1; + notify_event.data = handler; + if ((size_t) write(notify_fd, &inc, sizeof(uint64_t)) != sizeof(uint64_t)) { ngx_log_error(NGX_LOG_ALERT, notify_event.log, ngx_errno, "write() to eventfd %d failed", notify_fd); return NGX_ERROR; } - notify_event.data = handler; - return NGX_OK; }