]> git.kaiwu.me - nginx.git/commitdiff
Events: fixed possible crash on start or reload.
authorValentin Bartenev <vbart@nginx.com>
Fri, 27 Mar 2015 18:19:20 +0000 (21:19 +0300)
committerValentin Bartenev <vbart@nginx.com>
Fri, 27 Mar 2015 18:19:20 +0000 (21:19 +0300)
The main thread could wake up and start processing the notify event
before the handler was set.

src/event/modules/ngx_epoll_module.c

index 5f7f67859e6b94c6d96e9fa6a1f6f7d37597e8ee..3458b209ae7aeffbace3ef77947ecf28d37bb160 100644 (file)
@@ -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;
 }