improper mutex re-initialization
eponymous alias
eponymousalias at yahoo.com
Sat Apr 25 01:37:18 CEST 2009
The comments I'm making here are relative to nagios 3.0.6 code.
In base/utils.c, init_command_file_worker_thread() contains a
call to pthread_mutex_init(). But there are paths through the
code wherein init_command_file_worker_thread() might be called
a second time. (If nagios is restarted,
shutdown_command_file_worker_thread() and then open_command_file(),
which calls init_command_file_worker_thread(), would be called,
and this would result in a second call to pthread_mutex_init() on
the same mutex.) However, initializing an initialized mutex
results in undefined behavior. The best fix is probably not to try
to dynamically initialize the external_command_buffer.buffer_lock
mutex. Rather, it should be statically initialized in nagios.c,
where external_command_buffer is defined:
circular_buffer external_command_buffer = {
NULL, /* void **buffer; */
0, /* int tail; */
0, /* int head; */
0, /* int items; */
0, /* int high; */
0L, /* unsigned long overflow; */
PTHREAD_MUTEX_INITIALIZER /* pthread_mutex_t buffer_lock; */
};
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
More information about the Developers
mailing list