Is this thread bug?

feneyer nginx-forum at
Wed Feb 22 07:00:11 UTC 2012

    I have to use nginx's muti-thread model. Presently, i am using and
modifying it. But i have some problems about nginx's thread processing:
    (1) in funcion "ngx_worker_thread_cycle", there is such codes which
i think is a mistake:
        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;
        ==>why call twice?
    (2)in function "ngx_event_expire_timers", lock problem as

        root = ngx_event_timer_rbtree.root;

        if (root == sentinel) {
        ==>return without call ngx_mutex_unlock?
    (3) in function "ngx_epoll_process_events",lock problem too:
        before the code "call rev->handler(rev);" ,it has call
"ngx_mutex_lock(ngx_posted_events_mutex)",but the handler recursively
call other functions wich may need the lock("ngx_posted_events_mutex")
too,then deadlock happens.
       I just simply modify it as follows:
       ngx_mutex_unlock(ngx_posted_events_mutex); //xxx 
        ngx_mutex_lock(ngx_posted_events_mutex); //xxx 
      ===>whether this modifying will bring on other unconspicuous

    Is there any solutions for nginx’s muti-threads using?Is there any
plan to support muti-threads?about when?
    I am looking forward to your reply.
    Thanks a lot.

Posted at Nginx Forum:,222829,222829#msg-222829

More information about the nginx mailing list