From b6029a8a3fbe8577386a2a5e67c86700900afaf6 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Fri, 20 Mar 2015 06:43:19 +0300 Subject: [PATCH] Removed unix ngx_threaded and related ngx_process_changes. --- src/event/modules/ngx_aio_module.c | 1 - src/event/modules/ngx_devpoll_module.c | 1 - src/event/modules/ngx_epoll_module.c | 1 - src/event/modules/ngx_eventport_module.c | 1 - src/event/modules/ngx_iocp_module.c | 1 - src/event/modules/ngx_kqueue_module.c | 95 ++------------------- src/event/modules/ngx_poll_module.c | 1 - src/event/modules/ngx_rtsig_module.c | 1 - src/event/modules/ngx_select_module.c | 1 - src/event/modules/ngx_win32_select_module.c | 1 - src/event/ngx_event.c | 2 +- src/event/ngx_event.h | 2 - src/os/unix/ngx_process_cycle.c | 1 - src/os/unix/ngx_process_cycle.h | 1 - 14 files changed, 10 insertions(+), 100 deletions(-) diff --git a/src/event/modules/ngx_aio_module.c b/src/event/modules/ngx_aio_module.c index 5df58d24c..fd03fecb4 100644 --- a/src/event/modules/ngx_aio_module.c +++ b/src/event/modules/ngx_aio_module.c @@ -49,7 +49,6 @@ ngx_event_module_t ngx_aio_module_ctx = { NULL, /* add an connection */ ngx_aio_del_connection, /* delete an connection */ NULL, /* trigger a notify */ - NULL, /* process the changes */ ngx_aio_process_events, /* process the events */ ngx_aio_init, /* init the events */ ngx_aio_done /* done the events */ diff --git a/src/event/modules/ngx_devpoll_module.c b/src/event/modules/ngx_devpoll_module.c index f651c9a56..fa8aebdf4 100644 --- a/src/event/modules/ngx_devpoll_module.c +++ b/src/event/modules/ngx_devpoll_module.c @@ -89,7 +89,6 @@ ngx_event_module_t ngx_devpoll_module_ctx = { NULL, /* add an connection */ NULL, /* delete an connection */ NULL, /* trigger a notify */ - NULL, /* process the changes */ ngx_devpoll_process_events, /* process the events */ ngx_devpoll_init, /* init the events */ ngx_devpoll_done, /* done the events */ diff --git a/src/event/modules/ngx_epoll_module.c b/src/event/modules/ngx_epoll_module.c index addb4477b..5f7f67859 100644 --- a/src/event/modules/ngx_epoll_module.c +++ b/src/event/modules/ngx_epoll_module.c @@ -185,7 +185,6 @@ ngx_event_module_t ngx_epoll_module_ctx = { #else NULL, /* trigger a notify */ #endif - NULL, /* process the changes */ ngx_epoll_process_events, /* process the events */ ngx_epoll_init, /* init the events */ ngx_epoll_done, /* done the events */ diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c index 0ab459ee8..bacbb0507 100644 --- a/src/event/modules/ngx_eventport_module.c +++ b/src/event/modules/ngx_eventport_module.c @@ -182,7 +182,6 @@ ngx_event_module_t ngx_eventport_module_ctx = { NULL, /* add an connection */ NULL, /* delete an connection */ ngx_eventport_notify, /* trigger a notify */ - NULL, /* process the changes */ ngx_eventport_process_events, /* process the events */ ngx_eventport_init, /* init the events */ ngx_eventport_done, /* done the events */ diff --git a/src/event/modules/ngx_iocp_module.c b/src/event/modules/ngx_iocp_module.c index 2ddf6ea71..7514e6fa5 100644 --- a/src/event/modules/ngx_iocp_module.c +++ b/src/event/modules/ngx_iocp_module.c @@ -65,7 +65,6 @@ ngx_event_module_t ngx_iocp_module_ctx = { NULL, /* add an connection */ ngx_iocp_del_connection, /* delete an connection */ NULL, /* trigger a notify */ - NULL, /* process the changes */ ngx_iocp_process_events, /* process the events */ ngx_iocp_init, /* init the events */ ngx_iocp_done /* done the events */ diff --git a/src/event/modules/ngx_kqueue_module.c b/src/event/modules/ngx_kqueue_module.c index 986687b0a..5573cb211 100644 --- a/src/event/modules/ngx_kqueue_module.c +++ b/src/event/modules/ngx_kqueue_module.c @@ -30,7 +30,6 @@ static ngx_int_t ngx_kqueue_set_event(ngx_event_t *ev, ngx_int_t filter, #ifdef EVFILT_USER static ngx_int_t ngx_kqueue_notify(ngx_event_handler_pt handler); #endif -static ngx_int_t ngx_kqueue_process_changes(ngx_cycle_t *cycle, ngx_uint_t try); static ngx_int_t ngx_kqueue_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags); static ngx_inline void ngx_kqueue_dump_event(ngx_log_t *log, @@ -42,15 +41,7 @@ static char *ngx_kqueue_init_conf(ngx_cycle_t *cycle, void *conf); int ngx_kqueue = -1; -/* - * The "change_list" should be declared as ngx_thread_volatile. - * However, the use of the change_list is localized in kqueue functions and - * is protected by the mutex so even the "icc -ipo" should not build the code - * with the race condition. Thus we avoid the declaration to make a more - * readable code. - */ - -static struct kevent *change_list, *change_list0, *change_list1; +static struct kevent *change_list; static struct kevent *event_list; static ngx_uint_t max_changes, nchanges, nevents; @@ -99,7 +90,6 @@ ngx_event_module_t ngx_kqueue_module_ctx = { #else NULL, /* trigger a notify */ #endif - ngx_kqueue_process_changes, /* process the changes */ ngx_kqueue_process_events, /* process the events */ ngx_kqueue_init, /* init the events */ ngx_kqueue_done /* done the events */ @@ -165,27 +155,15 @@ ngx_kqueue_init(ngx_cycle_t *cycle, ngx_msec_t timer) nchanges = 0; } - if (change_list0) { - ngx_free(change_list0); + if (change_list) { + ngx_free(change_list); } - change_list0 = ngx_alloc(kcf->changes * sizeof(struct kevent), - cycle->log); - if (change_list0 == NULL) { + change_list = ngx_alloc(kcf->changes * sizeof(struct kevent), + cycle->log); + if (change_list == NULL) { return NGX_ERROR; } - - if (change_list1) { - ngx_free(change_list1); - } - - change_list1 = ngx_alloc(kcf->changes * sizeof(struct kevent), - cycle->log); - if (change_list1 == NULL) { - return NGX_ERROR; - } - - change_list = change_list0; } max_changes = kcf->changes; @@ -290,12 +268,9 @@ ngx_kqueue_done(ngx_cycle_t *cycle) ngx_kqueue = -1; - ngx_free(change_list1); - ngx_free(change_list0); + ngx_free(change_list); ngx_free(event_list); - change_list1 = NULL; - change_list0 = NULL; change_list = NULL; event_list = NULL; max_changes = 0; @@ -531,17 +506,8 @@ ngx_kqueue_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_queue_t *queue; struct timespec ts, *tp; - if (ngx_threaded) { - if (ngx_kqueue_process_changes(cycle, 0) == NGX_ERROR) { - return NGX_ERROR; - } - - n = 0; - - } else { - n = (int) nchanges; - nchanges = 0; - } + n = (int) nchanges; + nchanges = 0; if (timer == NGX_TIMER_INFINITE) { tp = NULL; @@ -707,49 +673,6 @@ ngx_kqueue_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, } -static ngx_int_t -ngx_kqueue_process_changes(ngx_cycle_t *cycle, ngx_uint_t try) -{ - int n; - ngx_int_t rc; - ngx_err_t err; - struct timespec ts; - struct kevent *changes; - - if (nchanges == 0) { - return NGX_OK; - } - - changes = change_list; - if (change_list == change_list0) { - change_list = change_list1; - } else { - change_list = change_list0; - } - - n = (int) nchanges; - nchanges = 0; - - ts.tv_sec = 0; - ts.tv_nsec = 0; - - ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, - "kevent changes: %d", n); - - if (kevent(ngx_kqueue, changes, n, NULL, 0, &ts) == -1) { - err = ngx_errno; - ngx_log_error((err == NGX_EINTR) ? NGX_LOG_INFO : NGX_LOG_ALERT, - cycle->log, err, "kevent() failed"); - rc = NGX_ERROR; - - } else { - rc = NGX_OK; - } - - return rc; -} - - static ngx_inline void ngx_kqueue_dump_event(ngx_log_t *log, struct kevent *kev) { diff --git a/src/event/modules/ngx_poll_module.c b/src/event/modules/ngx_poll_module.c index b96c90874..e48a8227a 100644 --- a/src/event/modules/ngx_poll_module.c +++ b/src/event/modules/ngx_poll_module.c @@ -40,7 +40,6 @@ ngx_event_module_t ngx_poll_module_ctx = { NULL, /* add an connection */ NULL, /* delete an connection */ NULL, /* trigger a notify */ - NULL, /* process the changes */ ngx_poll_process_events, /* process the events */ ngx_poll_init, /* init the events */ ngx_poll_done /* done the events */ diff --git a/src/event/modules/ngx_rtsig_module.c b/src/event/modules/ngx_rtsig_module.c index 3777516b4..b120fecde 100644 --- a/src/event/modules/ngx_rtsig_module.c +++ b/src/event/modules/ngx_rtsig_module.c @@ -131,7 +131,6 @@ ngx_event_module_t ngx_rtsig_module_ctx = { ngx_rtsig_add_connection, /* add an connection */ ngx_rtsig_del_connection, /* delete an connection */ NULL, /* trigger a notify */ - NULL, /* process the changes */ ngx_rtsig_process_events, /* process the events */ ngx_rtsig_init, /* init the events */ ngx_rtsig_done, /* done the events */ diff --git a/src/event/modules/ngx_select_module.c b/src/event/modules/ngx_select_module.c index a8bf06676..46004e5fd 100644 --- a/src/event/modules/ngx_select_module.c +++ b/src/event/modules/ngx_select_module.c @@ -48,7 +48,6 @@ ngx_event_module_t ngx_select_module_ctx = { NULL, /* add an connection */ NULL, /* delete an connection */ NULL, /* trigger a notify */ - NULL, /* process the changes */ ngx_select_process_events, /* process the events */ ngx_select_init, /* init the events */ ngx_select_done /* done the events */ diff --git a/src/event/modules/ngx_win32_select_module.c b/src/event/modules/ngx_win32_select_module.c index 58b20db1e..c671f836b 100644 --- a/src/event/modules/ngx_win32_select_module.c +++ b/src/event/modules/ngx_win32_select_module.c @@ -49,7 +49,6 @@ ngx_event_module_t ngx_select_module_ctx = { NULL, /* add an connection */ NULL, /* delete an connection */ NULL, /* trigger a notify */ - NULL, /* process the changes */ ngx_select_process_events, /* process the events */ ngx_select_init, /* init the events */ ngx_select_done /* done the events */ diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c index 2a23d5038..885528aae 100644 --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -178,7 +178,7 @@ ngx_event_module_t ngx_event_core_module_ctx = { ngx_event_core_create_conf, /* create configuration */ ngx_event_core_init_conf, /* init configuration */ - { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } + { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } }; diff --git a/src/event/ngx_event.h b/src/event/ngx_event.h index 61ebcb089..fbd91fb0d 100644 --- a/src/event/ngx_event.h +++ b/src/event/ngx_event.h @@ -202,7 +202,6 @@ typedef struct { ngx_int_t (*notify)(ngx_event_handler_pt handler); - ngx_int_t (*process_changes)(ngx_cycle_t *cycle, ngx_uint_t nowait); ngx_int_t (*process_events)(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags); @@ -415,7 +414,6 @@ extern ngx_event_actions_t ngx_event_actions; #endif -#define ngx_process_changes ngx_event_actions.process_changes #define ngx_process_events ngx_event_actions.process_events #define ngx_done_events ngx_event_actions.done diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index beee6d44f..1d5e700a8 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -30,7 +30,6 @@ static void ngx_cache_loader_process_handler(ngx_event_t *ev); ngx_uint_t ngx_process; ngx_pid_t ngx_pid; -ngx_uint_t ngx_threaded; sig_atomic_t ngx_reap; sig_atomic_t ngx_sigio; diff --git a/src/os/unix/ngx_process_cycle.h b/src/os/unix/ngx_process_cycle.h index 94747b85d..d44c377ce 100644 --- a/src/os/unix/ngx_process_cycle.h +++ b/src/os/unix/ngx_process_cycle.h @@ -43,7 +43,6 @@ extern ngx_pid_t ngx_pid; extern ngx_pid_t ngx_new_binary; extern ngx_uint_t ngx_inherited; extern ngx_uint_t ngx_daemonized; -extern ngx_uint_t ngx_threaded; extern ngx_uint_t ngx_exiting; extern sig_atomic_t ngx_reap;