# Why not support multithread?

**URL:** <https://www.ruby-forum.com/t/why-not-support-multithread/177096>\
**Category:** NGINX\
**Created:** [October 11, 2009, 4:41pm UTC](https://www.ruby-forum.com/t/why-not-support-multithread/177096 "2009-10-11T16:41:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![bit\_bull](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@bit\_bull](https://www.ruby-forum.com/u/bit_bull)\
**Post date:** [October 11, 2009, 4:41pm UTC](https://www.ruby-forum.com/t/why-not-support-multithread/177096/1 "2009-10-11T16:41:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bit\_bull](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@bit\_bull](https://www.ruby-forum.com/u/bit_bull)\
**Post date:** [October 11, 2009, 4:47pm UTC](https://www.ruby-forum.com/t/why-not-support-multithread/177096/2 "2009-10-11T16:47:26Z")

</div>

On Sun, Oct 11, 2009 at 10:33:38PM +0800, bit bull wrote:

> * * *
> 
> ```
> if (root == sentinel) {
> } else {
> } else {
> 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?

The threads support in nginx is currently broken and this patch does not  
fix it.

---

<div class="post-metadata">

**Author:** ![bit\_bull](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@bit\_bull](https://www.ruby-forum.com/u/bit_bull)\
**Post date:** [October 11, 2009, 5:03pm UTC](https://www.ruby-forum.com/t/why-not-support-multithread/177096/3 "2009-10-11T17:03:50Z")

</div>

thanks Igor, I know this patch doesn’t fix it, it’s my test code.

Can you introduce more details about multithread’s “broken” (what  
problems is current version) ?

2009/10/11 Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![bit\_bull](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@bit\_bull](https://www.ruby-forum.com/u/bit_bull)\
**Post date:** [October 11, 2009, 5:12pm UTC](https://www.ruby-forum.com/t/why-not-support-multithread/177096/4 "2009-10-11T17:12:36Z")

</div>

On Sun, Oct 11, 2009 at 10:58:48PM +0800, bit bull wrote:

> thanks Igor, I know this patch doesn’t fix it, it’s my test code.
> 
> Can you introduce more details about multithread’s “broken” (what  
> problems is current version) ?

No, there are too many places required multithreaded handling.

---

<div class="post-metadata">

**Author:** ![bit\_bull](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/54ee81/32.png) [@bit\_bull](https://www.ruby-forum.com/u/bit_bull)\
**Post date:** [October 12, 2009, 5:30am UTC](https://www.ruby-forum.com/t/why-not-support-multithread/177096/5 "2009-10-12T05:30:58Z")

</div>

thanks for your help.

2009/10/11 Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
