[nginx] Removed old pthread implementation.

Ruslan Ermilov ru at nginx.com
Fri Mar 20 03:46:29 UTC 2015


details:   http://hg.nginx.org/nginx/rev/e284f3ff6831
branches:  
changeset: 6029:e284f3ff6831
user:      Ruslan Ermilov <ru at nginx.com>
date:      Fri Mar 20 06:43:19 2015 +0300
description:
Removed old pthread implementation.

diffstat:

 auto/sources                          |    2 -
 src/event/modules/ngx_kqueue_module.c |   50 ------
 src/os/unix/ngx_process_cycle.c       |  188 ----------------------
 src/os/unix/ngx_pthread_thread.c      |  278 ----------------------------------
 src/os/unix/ngx_thread.h              |   98 -----------
 src/os/unix/ngx_user.c                |   20 --
 6 files changed, 0 insertions(+), 636 deletions(-)

diffs (truncated from 835 to 300 lines):

diff -r fa77496b1df2 -r e284f3ff6831 auto/sources
--- a/auto/sources	Fri Mar 20 06:43:19 2015 +0300
+++ b/auto/sources	Fri Mar 20 06:43:19 2015 +0300
@@ -204,8 +204,6 @@ FREEBSD_DEPS="src/os/unix/ngx_freebsd_co
 FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c
 FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c
 
-PTHREAD_SRCS="src/os/unix/ngx_pthread_thread.c"
-
 LINUX_DEPS="src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux.h"
 LINUX_SRCS=src/os/unix/ngx_linux_init.c
 LINUX_SENDFILE_SRCS=src/os/unix/ngx_linux_sendfile_chain.c
diff -r fa77496b1df2 -r e284f3ff6831 src/event/modules/ngx_kqueue_module.c
--- a/src/event/modules/ngx_kqueue_module.c	Fri Mar 20 06:43:19 2015 +0300
+++ b/src/event/modules/ngx_kqueue_module.c	Fri Mar 20 06:43:19 2015 +0300
@@ -59,12 +59,6 @@ static ngx_event_t     notify_event;
 static struct kevent   notify_kev;
 #endif
 
-#if (NGX_OLD_THREADS)
-static ngx_mutex_t    *list_mutex;
-static ngx_mutex_t    *kevent_mutex;
-#endif
-
-
 
 static ngx_str_t      kqueue_name = ngx_string("kqueue");
 
@@ -154,20 +148,6 @@ ngx_kqueue_init(ngx_cycle_t *cycle, ngx_
             return NGX_ERROR;
         }
 #endif
-
-#if (NGX_OLD_THREADS)
-
-        list_mutex = ngx_mutex_init(cycle->log, 0);
-        if (list_mutex == NULL) {
-            return NGX_ERROR;
-        }
-
-        kevent_mutex = ngx_mutex_init(cycle->log, 0);
-        if (kevent_mutex == NULL) {
-            return NGX_ERROR;
-        }
-
-#endif
     }
 
     if (max_changes < kcf->changes) {
@@ -310,11 +290,6 @@ ngx_kqueue_done(ngx_cycle_t *cycle)
 
     ngx_kqueue = -1;
 
-#if (NGX_OLD_THREADS)
-    ngx_mutex_destroy(kevent_mutex);
-    ngx_mutex_destroy(list_mutex);
-#endif
-
     ngx_free(change_list1);
     ngx_free(change_list0);
     ngx_free(event_list);
@@ -342,8 +317,6 @@ ngx_kqueue_add_event(ngx_event_t *ev, ng
     ev->disabled = 0;
     ev->oneshot = (flags & NGX_ONESHOT_EVENT) ? 1 : 0;
 
-    ngx_mutex_lock(list_mutex);
-
 #if 0
 
     if (ev->index < nchanges
@@ -368,8 +341,6 @@ ngx_kqueue_add_event(ngx_event_t *ev, ng
                 e->index = ev->index;
             }
 
-            ngx_mutex_unlock(list_mutex);
-
             return NGX_OK;
         }
 
@@ -378,8 +349,6 @@ ngx_kqueue_add_event(ngx_event_t *ev, ng
         ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
                       "previous event on #%d were not passed in kernel", c->fd);
 
-        ngx_mutex_unlock(list_mutex);
-
         return NGX_ERROR;
     }
 
@@ -387,8 +356,6 @@ ngx_kqueue_add_event(ngx_event_t *ev, ng
 
     rc = ngx_kqueue_set_event(ev, event, EV_ADD|EV_ENABLE|flags);
 
-    ngx_mutex_unlock(list_mutex);
-
     return rc;
 }
 
@@ -402,8 +369,6 @@ ngx_kqueue_del_event(ngx_event_t *ev, ng
     ev->active = 0;
     ev->disabled = 0;
 
-    ngx_mutex_lock(list_mutex);
-
     if (ev->index < nchanges
         && ((uintptr_t) change_list[ev->index].udata & (uintptr_t) ~1)
             == (uintptr_t) ev)
@@ -423,8 +388,6 @@ ngx_kqueue_del_event(ngx_event_t *ev, ng
             e->index = ev->index;
         }
 
-        ngx_mutex_unlock(list_mutex);
-
         return NGX_OK;
     }
 
@@ -435,7 +398,6 @@ ngx_kqueue_del_event(ngx_event_t *ev, ng
      */
 
     if (flags & NGX_CLOSE_EVENT) {
-        ngx_mutex_unlock(list_mutex);
         return NGX_OK;
     }
 
@@ -448,8 +410,6 @@ ngx_kqueue_del_event(ngx_event_t *ev, ng
 
     rc = ngx_kqueue_set_event(ev, event, flags);
 
-    ngx_mutex_unlock(list_mutex);
-
     return rc;
 }
 
@@ -756,13 +716,7 @@ ngx_kqueue_process_changes(ngx_cycle_t *
     struct timespec   ts;
     struct kevent    *changes;
 
-    ngx_mutex_lock(kevent_mutex);
-
-    ngx_mutex_lock(list_mutex);
-
     if (nchanges == 0) {
-        ngx_mutex_unlock(list_mutex);
-        ngx_mutex_unlock(kevent_mutex);
         return NGX_OK;
     }
 
@@ -776,8 +730,6 @@ ngx_kqueue_process_changes(ngx_cycle_t *
     n = (int) nchanges;
     nchanges = 0;
 
-    ngx_mutex_unlock(list_mutex);
-
     ts.tv_sec = 0;
     ts.tv_nsec = 0;
 
@@ -794,8 +746,6 @@ ngx_kqueue_process_changes(ngx_cycle_t *
         rc = NGX_OK;
     }
 
-    ngx_mutex_unlock(kevent_mutex);
-
     return rc;
 }
 
diff -r fa77496b1df2 -r e284f3ff6831 src/os/unix/ngx_process_cycle.c
--- a/src/os/unix/ngx_process_cycle.c	Fri Mar 20 06:43:19 2015 +0300
+++ b/src/os/unix/ngx_process_cycle.c	Fri Mar 20 06:43:19 2015 +0300
@@ -23,10 +23,6 @@ static void ngx_worker_process_cycle(ngx
 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 *cy
 
     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 *cyc
     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();



More information about the nginx-devel mailing list