[nginx] Events: fixed possible crash on start or reload.

Valentin Bartenev vbart at nginx.com
Fri Mar 27 18:21:12 UTC 2015


details:   http://hg.nginx.org/nginx/rev/953ef81705e1
branches:  
changeset: 6061:953ef81705e1
user:      Valentin Bartenev <vbart at nginx.com>
date:      Fri Mar 27 21:19:20 2015 +0300
description:
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.

diffstat:

 src/event/modules/ngx_epoll_module.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (20 lines):

diff -r 3d4730eada9c -r 953ef81705e1 src/event/modules/ngx_epoll_module.c
--- a/src/event/modules/ngx_epoll_module.c	Fri Mar 27 19:57:15 2015 +0300
+++ b/src/event/modules/ngx_epoll_module.c	Fri Mar 27 21:19:20 2015 +0300
@@ -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;
 }
 



More information about the nginx-devel mailing list