diff options
author | Ruslan Ermilov <ru@nginx.com> | 2015-03-20 06:43:19 +0300 |
---|---|---|
committer | Ruslan Ermilov <ru@nginx.com> | 2015-03-20 06:43:19 +0300 |
commit | d1ec868e328f58fc2c96827f4d1223ee7ed2192c (patch) | |
tree | f0a60acf5de2d5c048f9aae21abd816c3ef6e663 /src/os/unix/ngx_process_cycle.c | |
parent | c84c19f5bf9b5e93056789940e38634fdb27a5e8 (diff) | |
download | nginx-d1ec868e328f58fc2c96827f4d1223ee7ed2192c.tar.gz nginx-d1ec868e328f58fc2c96827f4d1223ee7ed2192c.zip |
Removed old pthread implementation.
Diffstat (limited to 'src/os/unix/ngx_process_cycle.c')
-rw-r--r-- | src/os/unix/ngx_process_cycle.c | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index 83d65dde6..beee6d44f 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -23,10 +23,6 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data); static void ngx_worker_process_init(ngx_cycle_t *cycle, ngx_int_t worker); static void ngx_worker_process_exit(ngx_cycle_t *cycle); static void ngx_channel_handler(ngx_event_t *ev); -#if (NGX_OLD_THREADS) -static void ngx_wakeup_worker_threads(ngx_cycle_t *cycle); -static ngx_thread_value_t ngx_worker_thread_cycle(void *data); -#endif static void ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data); static void ngx_cache_manager_process_handler(ngx_event_t *ev); static void ngx_cache_loader_process_handler(ngx_event_t *ev); @@ -56,12 +52,6 @@ ngx_uint_t ngx_noaccepting; ngx_uint_t ngx_restart; -#if (NGX_OLD_THREADS) -volatile ngx_thread_t ngx_threads[NGX_MAX_THREADS]; -ngx_int_t ngx_threads_n; -#endif - - static u_char master_process[] = "master process"; @@ -747,52 +737,6 @@ ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data) ngx_setproctitle("worker process"); -#if (NGX_OLD_THREADS) - { - ngx_int_t n; - ngx_err_t err; - ngx_core_conf_t *ccf; - - ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); - - if (ngx_threads_n) { - if (ngx_init_threads(ngx_threads_n, ccf->thread_stack_size, cycle) - == NGX_ERROR) - { - /* fatal */ - exit(2); - } - - err = ngx_thread_key_create(&ngx_core_tls_key); - if (err != 0) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, err, - ngx_thread_key_create_n " failed"); - /* fatal */ - exit(2); - } - - for (n = 0; n < ngx_threads_n; n++) { - - ngx_threads[n].cv = ngx_cond_init(cycle->log); - - if (ngx_threads[n].cv == NULL) { - /* fatal */ - exit(2); - } - - if (ngx_create_thread((ngx_tid_t *) &ngx_threads[n].tid, - ngx_worker_thread_cycle, - (void *) &ngx_threads[n], cycle->log) - != 0) - { - /* fatal */ - exit(2); - } - } - } - } -#endif - for ( ;; ) { if (ngx_exiting) { @@ -1032,12 +976,6 @@ ngx_worker_process_exit(ngx_cycle_t *cycle) ngx_uint_t i; ngx_connection_t *c; -#if (NGX_OLD_THREADS) - ngx_terminate = 1; - - ngx_wakeup_worker_threads(cycle); -#endif - for (i = 0; ngx_modules[i]; i++) { if (ngx_modules[i]->exit_process) { ngx_modules[i]->exit_process(cycle); @@ -1181,132 +1119,6 @@ ngx_channel_handler(ngx_event_t *ev) } -#if (NGX_OLD_THREADS) - -static void -ngx_wakeup_worker_threads(ngx_cycle_t *cycle) -{ - ngx_int_t i; - ngx_uint_t live; - - for ( ;; ) { - - live = 0; - - for (i = 0; i < ngx_threads_n; i++) { - if (ngx_threads[i].state < NGX_THREAD_EXIT) { - if (ngx_cond_signal(ngx_threads[i].cv) == NGX_ERROR) { - ngx_threads[i].state = NGX_THREAD_DONE; - - } else { - live = 1; - } - } - - if (ngx_threads[i].state == NGX_THREAD_EXIT) { - ngx_thread_join(ngx_threads[i].tid, NULL); - ngx_threads[i].state = NGX_THREAD_DONE; - } - } - - if (live == 0) { - ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0, - "all worker threads are joined"); - - /* STUB */ - ngx_done_events(cycle); - - return; - } - - ngx_sched_yield(); - } -} - - -static ngx_thread_value_t -ngx_worker_thread_cycle(void *data) -{ - ngx_thread_t *thr = data; - - sigset_t set; - ngx_err_t err; - ngx_core_tls_t *tls; - ngx_cycle_t *cycle; - - cycle = (ngx_cycle_t *) ngx_cycle; - - sigemptyset(&set); - sigaddset(&set, ngx_signal_value(NGX_RECONFIGURE_SIGNAL)); - sigaddset(&set, ngx_signal_value(NGX_REOPEN_SIGNAL)); - sigaddset(&set, ngx_signal_value(NGX_CHANGEBIN_SIGNAL)); - - err = ngx_thread_sigmask(SIG_BLOCK, &set, NULL); - if (err) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, err, - ngx_thread_sigmask_n " failed"); - return (ngx_thread_value_t) 1; - } - - ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, - "thread " NGX_TID_T_FMT " started", ngx_thread_self()); - - ngx_setthrtitle("worker thread"); - - tls = ngx_calloc(sizeof(ngx_core_tls_t), cycle->log); - if (tls == NULL) { - return (ngx_thread_value_t) 1; - } - - err = ngx_thread_set_tls(ngx_core_tls_key, tls); - if (err != 0) { - ngx_log_error(NGX_LOG_ALERT, cycle->log, err, - ngx_thread_set_tls_n " failed"); - return (ngx_thread_value_t) 1; - } - - for ( ;; ) { - thr->state = NGX_THREAD_FREE; - -#if 0 - if (ngx_cond_wait(thr->cv, ngx_posted_events_mutex) == NGX_ERROR) { - return (ngx_thread_value_t) 1; - } -#endif - - if (ngx_terminate) { - thr->state = NGX_THREAD_EXIT; - - ngx_log_debug1(NGX_LOG_DEBUG_CORE, cycle->log, 0, - "thread " NGX_TID_T_FMT " is done", - ngx_thread_self()); - - return (ngx_thread_value_t) 0; - } - - thr->state = NGX_THREAD_BUSY; - -#if 0 - if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) { - return (ngx_thread_value_t) 1; - } - - if (ngx_event_thread_process_posted(cycle) == NGX_ERROR) { - return (ngx_thread_value_t) 1; - } -#endif - - if (ngx_process_changes) { - if (ngx_process_changes(cycle, 1) == NGX_ERROR) { - return (ngx_thread_value_t) 1; - } - } - } -} - -#endif - - static void ngx_cache_manager_process_cycle(ngx_cycle_t *cycle, void *data) { |