[Fedora-directory-commits] ldapserver/ldap/servers/slapd log.c, 1.25, 1.26
Noriko Hosoi
nhosoi at fedoraproject.org
Fri Mar 13 16:39:29 UTC 2009
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv20986
Modified Files:
log.c
Log Message:
Resolves: #489625
Summary: If an independent process db2ldif rotates the error log, it crashes the server.
Description: PR_Rename failure due to the FILE_EXIST is benign. Ignore the
error and goes forward. The procedure is extended to all the log type: error,
access, and audit.
Index: log.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/log.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- log.c 10 Dec 2008 06:23:24 -0000 1.25
+++ log.c 13 Mar 2009 16:39:25 -0000 1.26
@@ -2144,9 +2144,15 @@
log_convert_time (log->l_ctime, tbuf, 1 /*short */);
PR_snprintf(newfile, sizeof(newfile), "%s.%s", loginfo.log_access_file, tbuf);
if (PR_Rename (loginfo.log_access_file, newfile) != PR_SUCCESS) {
- loginfo.log_access_fdes = NULL;
- if (!locked) LOG_ACCESS_UNLOCK_WRITE();
- return LOG_UNABLE_TO_OPENFILE;
+ PRErrorCode prerr = PR_GetError();
+ /* Make "FILE EXISTS" error an exception.
+ Even if PR_Rename fails with the error, we continue logging.
+ */
+ if (PR_FILE_EXISTS_ERROR != prerr) {
+ loginfo.log_access_fdes = NULL;
+ if (!locked) LOG_ACCESS_UNLOCK_WRITE();
+ return LOG_UNABLE_TO_OPENFILE;
+ }
}
/* add the log to the chain */
log->l_next = loginfo.log_access_logchain;
@@ -3202,7 +3208,7 @@
* which causes the self deadlock if you call LDAPDebug for logging.
* Thus, instead of LDAPDebug, call log__error_emergency with locked == 1. */
PR_snprintf(buffer, sizeof(buffer), "LOGINFO:Unable to remove file:%s.%s\n",
- loginfo.log_audit_file, tbuf);
+ loginfo.log_audit_file, tbuf);
log__error_emergency(buffer, 0, locked);
}
slapi_ch_free((void**)&delete_logp);
@@ -3638,14 +3644,19 @@
PR_snprintf(newfile, sizeof(newfile), "%s.%s", loginfo.log_error_file, tbuf);
if (PR_Rename (loginfo.log_error_file, newfile) != PR_SUCCESS) {
PRErrorCode prerr = PR_GetError();
- PR_snprintf(buffer, sizeof(buffer),
- "Failed to rename errors log file, "
- SLAPI_COMPONENT_NAME_NSPR " error %d (%s). Exiting...",
- prerr, slapd_pr_strerror(prerr));
- log__error_emergency(buffer, 1, 1);
- slapi_ch_free((void **)&log);
- if (!locked) LOG_ERROR_UNLOCK_WRITE();
- return LOG_UNABLE_TO_OPENFILE;
+ /* Make "FILE EXISTS" error an exception.
+ Even if PR_Rename fails with the error, we continue logging.
+ */
+ if (PR_FILE_EXISTS_ERROR != prerr) {
+ PR_snprintf(buffer, sizeof(buffer),
+ "Failed to rename errors log file, "
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s). Exiting...",
+ prerr, slapd_pr_strerror(prerr));
+ log__error_emergency(buffer, 1, 1);
+ slapi_ch_free((void **)&log);
+ if (!locked) LOG_ERROR_UNLOCK_WRITE();
+ return LOG_UNABLE_TO_OPENFILE;
+ }
}
/* add the log to the chain */
@@ -3776,8 +3787,14 @@
log_convert_time (log->l_ctime, tbuf, 1 /*short */);
PR_snprintf(newfile, sizeof(newfile), "%s.%s", loginfo.log_audit_file, tbuf);
if (PR_Rename (loginfo.log_audit_file, newfile) != PR_SUCCESS) {
- if (!locked) LOG_AUDIT_UNLOCK_WRITE();
- return LOG_UNABLE_TO_OPENFILE;
+ PRErrorCode prerr = PR_GetError();
+ /* Make "FILE EXISTS" error an exception.
+ Even if PR_Rename fails with the error, we continue logging.
+ */
+ if (PR_FILE_EXISTS_ERROR != prerr) {
+ if (!locked) LOG_AUDIT_UNLOCK_WRITE();
+ return LOG_UNABLE_TO_OPENFILE;
+ }
}
/* add the log to the chain */
More information about the Fedora-directory-commits
mailing list