why not support multithread?

bit bull bitbull.cn at gmail.com
Sun Oct 11 18:33:38 MSD 2009


hi, all:

     I saw multithread is supported at Nginx SourceCode. But complie
configure hiden this feature.

     I modified some source to open it, then run Nginx. DeathLock(lock
and lock again) happened, Nginx is Hanging.

    I modified two files to solution this problem:

---------------------------------------------------------------------------------------------------------------------------
--- nginx-0.8.19/src/event/ngx_event_timer.c	2009-10-11 19:49:04.000000000 +0800
+++ src/event/ngx_event_timer.c	2009-10-11 18:19:44.000000000 +0800
@@ -82,11 +82,13 @@

     for ( ;; ) {

         ngx_mutex_lock(ngx_event_timer_mutex);

         root = ngx_event_timer_rbtree.root;

         if (root == sentinel) {
+            ngx_mutex_unlock(ngx_event_timer_mutex);
             return;

--- nginx-0.8.19/src/event/modules/ngx_epoll_module.c	2009-10-11
19:49:04.000000000 +0800
+++ src/event/modules/ngx_epoll_module.c	2009-10-11 19:43:56.000000000 +0800

@@ -639,7 +639,10 @@
                 ngx_locked_post_event(rev, queue);

             } else {
+
+		ngx_mutex_unlock(ngx_posted_events_mutex);
                 rev->handler(rev);
+		ngx_mutex_lock(ngx_posted_events_mutex);
             }
         }

@@ -658,12 +661,15 @@
                 ngx_locked_post_event(wev, &ngx_posted_events);

             } else {
+
+		ngx_mutex_unlock(ngx_posted_events_mutex);
                 wev->handler(wev);
+		ngx_mutex_lock(ngx_posted_events_mutex);
             }
         }
     }
---------------------------------------------------------------------------------------------------------------------------


        Now it run, and seem no problem (I feeling have some problems yet).
        I what to know why not support multithread in public, have
other problem in current version?

thanks~
bb





More information about the nginx mailing list