[Nagios-checkins] SF.net SVN: nagios:[1839] nagioscore/trunk/common/downtime.c
Nagios network monitoring software is enterprise server monitoring
Brought to you by:
egalstad,
sawolf-nagios
From: <ag...@us...> - 2011-11-21 20:51:39
|
Revision: 1839 http://nagios.svn.sourceforge.net/nagios/?rev=1839&view=rev Author: ageric Date: 2011-11-21 20:51:29 +0000 (Mon, 21 Nov 2011) Log Message: ----------- core: fix possible race condition on downtime list lock When deleting a downtime, the newly introduced nagios_downtime_lock mutex gets locked to prevent threads from fiddling in there. After having fetched the downtime we want to delete we only try to if !NULL and then releasing the mutex. If a module has already manipulated the list in memory and deleted the downtime, the condition runs into the else-tree returning an error and the mutex will be kept locked forever. In order to fix that we move the unlocking outside the if condition, let memory being free'd or result being an error and then savely unlock the downtime list. This will prevent us from running into a possible race condition leaving the core idle wait for the mutex on deleting a comment. Pached-by: Michael Friedrich <mic...@un...> Signed-off-by: Andreas Ericsson <ae...@op...> Modified Paths: -------------- nagioscore/trunk/common/downtime.c Modified: nagioscore/trunk/common/downtime.c =================================================================== --- nagioscore/trunk/common/downtime.c 2011-11-21 20:51:12 UTC (rev 1838) +++ nagioscore/trunk/common/downtime.c 2011-11-21 20:51:29 UTC (rev 1839) @@ -796,9 +796,6 @@ else last_downtime->next = next_downtime; -#ifdef NSCORE - pthread_mutex_unlock(&nagios_downtime_lock); -#endif /* free memory */ my_free(this_downtime->host_name); my_free(this_downtime->service_description); @@ -811,6 +808,10 @@ else result = ERROR; +#ifdef NSCORE + pthread_mutex_unlock(&nagios_downtime_lock); +#endif + return result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |