summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2015-03-27 21:19:20 +0300
committerValentin Bartenev <vbart@nginx.com>2015-03-27 21:19:20 +0300
commit51df7912c4a1320ead61cb57acdeaf16ffdcc289 (patch)
tree77c9fedcf0d072ccc49669506dffe28629c3a5c9
parent3ffbf84a5ee72bfb466c4e2209fd5691ec67f790 (diff)
downloadnginx-51df7912c4a1320ead61cb57acdeaf16ffdcc289.tar.gz
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.
-rw-r--r--src/event/modules/ngx_epoll_module.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c
index 5f7f67859..3458b209a 100644
--- 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 handler)
{
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;
}