Opened 13 years ago
Closed 13 years ago
#138 closed defect (fixed)
Does ngx_mutex_init have an error?
Reported by: | Vincent Lee | Owned by: | somebody |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | other | Version: | 1.1.x |
Keywords: | ngx_mutex_init | Cc: | win32 |
uname -a: | win32 | ||
nginx -V: | nginx version: nginx/1.1.16 |
Description
.\nginx\src\os\win32\ngx_thread.c
#if (NGX_THREADS)
ngx_mutex_t *ngx_event_timer_mutex; this ngx_event_timer_mutex is a pointer.
#endif
ngx_mutex_t *
ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags)
{
return (ngx_mutex_t *) 1;convert 1 to "ngx_mutex_t *" ???
}
ngx_int_t
ngx_event_timer_init(ngx_log_t *log)
{
ngx_rbtree_init(&ngx_event_timer_rbtree, &ngx_event_timer_sentinel,
ngx_rbtree_insert_timer_value);
#if (NGX_THREADS)
if (ngx_event_timer_mutex) { ngx_event_timer_mutex is 1
ngx_event_timer_mutex->log = log;here will be error...
return NGX_OK;
}
ngx_event_timer_mutex = ngx_mutex_init(log, 0);
if (ngx_event_timer_mutex == NULL) {
return NGX_ERROR;
}
#endif
return NGX_OK;
}
as you see, ngx_mutex_init converts 1 to a "ngx_mutex_t *" pointer, and if we do "ngx_event_timer_mutex->log = log;", it will tigger errors.
Change History (7)
follow-up: 3 comment:1 by , 13 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 13 years ago
yes, if master_process is on, the ngx_event_timer_init() is only called once on process startup. but if master_process is off,of course it's maybe in the devoloping process... the ngx_event_timer_init() will be called more than once.call stack likes below:
1.
nginx_vc9.exe!ngx_event_timer_init(ngx_log_s * log=0x009565bc) line31 C
nginx_vc9.exe!ngx_event_process_init(ngx_cycle_s * cycle=0x009565b0) line607 + 0xc bytes C
nginx_vc9.exe!ngx_single_process_cycle(ngx_cycle_s * cycle=0x009565b0) line1039 + 0x15 bytes C
nginx_vc9.exe!main(int argc=1, char * const * argv=0x00a32540) line409 + 0x9 bytes C
nginx_vc9.exe__tmainCRTStartup() line266 + 0x19 bytes C
nginx_vc9.exe!mainCRTStartup() line182 C
2.
nginx_vc9.exe!ngx_event_timer_init(ngx_log_s * log=0x009565bc) line31 C
nginx_vc9.exe!ngx_event_process_init(ngx_cycle_s * cycle=0x009565b0) line607 + 0xc bytes C
nginx_vc9.exe!ngx_worker_thread(void * data=0x00000000) line810 + 0x15 bytes C
this case will happen when we set master_process to be off on win32. so it's better to remove this hidden trouble.
comment:3 by , 13 years ago
Replying to Maxim Dounin:
The ngx_event_timer_init() is only called once on process startup, and this will never happen under win32 as there is no fork() there and ngx_event_timer_mutex is always NULL on ngx_event_timer_init() call.
yes, if master_process is on, the ngx_event_timer_init() is only called once on process startup. but if master_process is off,of course it's maybe in the devoloping process... the ngx_event_timer_init() will be called more than once.
please see comment2 to get more details.
comment:5 by , 13 years ago
Status: | reopened → accepted |
---|
The ngx_event_timer_init() is only called once on process startup, and this will never happen under win32 as there is no fork() there and ngx_event_timer_mutex is always NULL on ngx_event_timer_init() call.