Update of /cvsroot/nagios/nagios/xdata
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29154/xdata
Modified Files:
xrddefault.c
Log Message:
Bug fixes, etc.
Index: xrddefault.c
===================================================================
RCS file: /cvsroot/nagios/nagios/xdata/xrddefault.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** xrddefault.c 11 Jan 2005 04:53:08 -0000 1.26
--- xrddefault.c 19 Mar 2005 22:16:06 -0000 1.27
***************
*** 4,8 ****
*
* Copyright (c) 1999-2005 Ethan Galstad (nagios@xxxxxxxxxx)
! * Last Modified: 01-10-2005
*
* License:
--- 4,8 ----
*
* Copyright (c) 1999-2005 Ethan Galstad (nagios@xxxxxxxxxx)
! * Last Modified: 03-19-2005
*
* License:
***************
*** 70,73 ****
--- 70,74 ----
char xrddefault_retention_file[MAX_FILENAME_LENGTH]="";
+ char xrddefault_temp_file[MAX_FILENAME_LENGTH]="";
***************
*** 86,90 ****
--- 87,93 ----
/* initialize the location of the retention file */
strncpy(xrddefault_retention_file,DEFAULT_RETENTION_FILE,sizeof(xrddefault_retention_file)-1);
+
strncpy(xrddefault_temp_file,DEFAULT_TEMP_FILE,sizeof(xrddefault_temp_file)-1);
xrddefault_retention_file[sizeof(xrddefault_retention_file)-1]='\x0';
+ xrddefault_temp_file[sizeof(xrddefault_temp_file)-1]='\x0';
/* open the main config file for reading */
***************
*** 150,159 ****
int xrddefault_save_state_information(char *main_config_file){
char temp_buffer[MAX_INPUT_BUFFER];
time_t current_time;
int result=OK;
! FILE *fp;
host *temp_host=NULL;
service *temp_service=NULL;
! int x;
#ifdef DEBUG0
--- 153,163 ----
int xrddefault_save_state_information(char *main_config_file){
char temp_buffer[MAX_INPUT_BUFFER];
+ char temp_file[MAX_FILENAME_LENGTH];
time_t current_time;
int result=OK;
! FILE *fp=NULL;
host *temp_host=NULL;
service *temp_service=NULL;
! int x, fd=0;
#ifdef DEBUG0
***************
*** 171,179 ****
}
! /* open the retention file for writing */
! fp=fopen(xrddefault_retention_file,"w");
if(fp==NULL){
! snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not
open state retention file '%s' for writing!\n",xrddefault_retention_file);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE);
--- 175,190 ----
}
! /* open a safe temp file for output */
! snprintf(temp_file,sizeof(temp_file)-1,"%sXXXXXX",xrddefault_temp_file);
! temp_file[sizeof(temp_file)-1]='\x0';
! if((fd=mkstemp(temp_file))==-1)
! return ERROR;
! fp=fdopen(fd,"w");
if(fp==NULL){
! close(fd);
! unlink(temp_file);
!
! snprintf(temp_buffer,sizeof(temp_buffer)-1,"Error: Could not
open temp state retention file '%s' for writing!\n",temp_file);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_ERROR,TRUE);
***************
*** 330,333 ****
--- 341,347 ----
fclose(fp);
+ /* move the temp file to the retention file (overwrite the old
retention file) */
+ if(my_rename(temp_file,xrddefault_retention_file))
+ return ERROR;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
|