# Exception with ngx\_event\_timer\_init() in win32

**URL:** <https://www.ruby-forum.com/t/exception-with-ngx-event-timer-init-in-win32/209396>\
**Category:** NGINX\
**Created:** [July 13, 2011, 10:20am UTC](https://www.ruby-forum.com/t/exception-with-ngx-event-timer-init-in-win32/209396 "2011-07-13T10:20:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [July 13, 2011, 10:20am UTC](https://www.ruby-forum.com/t/exception-with-ngx-event-timer-init-in-win32/209396/1 "2011-07-13T10:20:26Z")

</div>

Hi,

In win32 native api file: ngx\_process\_cycle.c init\_process will call  
ngx\_event\_timer\_init(), but the function ngx\_mutex\_init() does not  
implement for win32 now, so ngx\_event\_timer\_mutex will be set to 1.

And this function ngx\_event\_timer\_init() will be called again in  
ngx\_worker\_thread(). The statement will access a invalid memory:

```
    ngx_event_timer_mutex->log = log;

```

Setting deamon and master\_process to off in nginx.conf, this exception  
will be reproduced.

So why ngx\_modules[n]-\>init\_process called twice in  
ngx\_single\_process\_cycle(), but ngx\_worker\_process\_cycle called once  
only?

```
for (n = 0; ngx_modules[n]; n++) {
    if (ngx_modules[n]->init_process) {
        if (ngx_modules[n]->init_process(cycle) == NGX_ERROR) {
            /* fatal */
            exit(2);
        }
    }
}

```

Posted at Nginx Forum:

> **[Exception with ngx\_event\_timer\_init() in win32](https://forum.nginx.org/read.php?2,212322,212322#msg-212322)**
>
> Hi, In win32 native api file: ngx\_process\_cycle.c init\_process will call ngx\_event\_timer\_init(), but the function ngx\_mutex\_init() does not implement for win32 now, so ngx\_event\_timer\_mutex will be set to 1. And this function ngx\_event\_timer\_init()...

---

<div class="post-metadata">

**Author:** ![bigplum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7c8e57/32.png) [@bigplum](https://www.ruby-forum.com/u/bigplum)\
**Post date:** [July 13, 2011, 3:13pm UTC](https://www.ruby-forum.com/t/exception-with-ngx-event-timer-init-in-win32/209396/2 "2011-07-13T15:13:17Z")

</div>

Hello!

On Wed, Jul 13, 2011 at 04:19:52AM -0400, bigplum wrote:

> ```
> /* fatal */
> exit(2);
> }
> }
> }
> 
> ```

Single process mode isn’t something that is expected to work  
flawlesly. Under unix it mostly works (except some problems with  
configuration reloading) and may be used for debugging. Under  
windows it’ll try to use threads and won’t work at all as a  
result.

Fixing this particular problem won’t help as there are plenty  
other thread-related problems. Please also note it’s listed in  
“possible future enchancements” list[1], and this future isn’t  
here right now. 🙂

[1] [nginx for Windows](http://nginx.org/en/docs/windows.html#possible_future_enhancements)

Maxim D.

---

<div class="post-metadata">

**Author:** ![bigplum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7c8e57/32.png) [@bigplum](https://www.ruby-forum.com/u/bigplum)\
**Post date:** [July 14, 2011, 4:57am UTC](https://www.ruby-forum.com/t/exception-with-ngx-event-timer-init-in-win32/209396/3 "2011-07-14T04:57:34Z")

</div>

Indeed, I think I could simply delete the init\_process from  
ngx\_single\_process\_cycle to let single process work.

Another question, most functions in file win32/ngx\_thread.c are not  
implemented, Is there anything consideration?

Posted at Nginx Forum:

> **[Re: Exception with ngx\_event\_timer\_init() in win32](https://forum.nginx.org/read.php?2,212322,212371#msg-212371)**
>
> Hi, In win32 native api file: ngx\_process\_cycle.c init\_process will call ngx\_event\_timer\_init(), but the function ngx\_mutex\_init() does not implement for win32 now, so ngx\_event\_timer\_mutex will be set to 1. And this function ngx\_event\_timer\_init()...
