2 calls to unlink in checkresults

Andreas Ericsson ae at op5.se
Tue May 19 11:01:28 CEST 2009


Mathieu Gagné wrote:
> Hi,
> 
> On 5/14/09 3:43 AM, Gerhard Lausser wrote:
>> i reported this bug in january
>> http://archive.netbsd.se/?ml=nagios-devel&a=2009-01&m=9671673
>> http://archive.netbsd.se/?ml=nagios-devel&a=2009-01&m=9671670
>> Imo, the condition for the second unlink needs to be reversed.
> 
> I think I found the source of the problem.
> 
> In base/checks.c, delete_check_result_file() is called within 
> reap_check_results():
> - From "/* service check */" at line 167 if it's a service checkresult 
> for an unknown service or
> - From "/* host check */" at line 192 if it's a host checkresult for an 
> unknown service or
> - at line 211 if it's processed normally.
> 
> However Nagios calls delete_check_result_file() in base/utils.c at line 
> 2486 too in process_check_result_queue() which is itself called from 
> base/checks at line 149 in reap_check_results() BEFORE the first case I 
> mentioned.
> 
> So basically it does:
> 
> reap_check_results()
>    process_check_result_queue()
>      /* For each files in checkresult */
>        process_check_result_file()
>          add_check_result_to_list()
>          delete_check_result_file()
>    /* For each files in checkresult */
>      Service: handle_async_service_check_result()
>      Host: handle_async_host_check_result_3x
>      delete_check_result_file()
> 
> Since process_check_result_queue() has already loaded all checkresult 
> files in a list in memory (by calling add_check_result_to_list() in 
> process_check_result_file()), reap_check_results() shouldn't call 
> delete_check_result_file() at all.
> 
> Does it make any sense to you?
> 

Yes, but it seems unnecessarily complex. I think I'll revamp it so
it's read once and deleted immediately after.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Register now for Nordic Meet on Nagios, June 3-4 in Stockholm
 http://nordicmeetonnagios.op5.org/

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing 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