public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE3 - logt: don't hold fd open when not required
@ 2009-01-27 6:32 Fabio M. Di Nitto
0 siblings, 0 replies; only message in thread
From: Fabio M. Di Nitto @ 2009-01-27 6:32 UTC (permalink / raw)
To: cluster-cvs-relay
Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=4bed7542f545c81d41e7dd7193fa6d3a8de3ad89
Commit: 4bed7542f545c81d41e7dd7193fa6d3a8de3ad89
Parent: ddb861cb47be92b89f3b853bf0dcce26bddeaf96
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate: Tue Jan 27 07:07:18 2009 +0100
Committer: Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Tue Jan 27 07:07:18 2009 +0100
logt: don't hold fd open when not required
fix corner case where we hold an fd open over a logfile
and we are not logging to file.
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
common/liblogthread/liblogthread.c | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/common/liblogthread/liblogthread.c b/common/liblogthread/liblogthread.c
index d0b28ad..9254a37 100644
--- a/common/liblogthread/liblogthread.c
+++ b/common/liblogthread/liblogthread.c
@@ -170,13 +170,20 @@ static void _conf(char *name, int mode, int syslog_facility,
strncpy(logt_logfile, logfile, PATH_MAX);
if (logt_mode & LOG_MODE_OUTPUT_FILE && logt_logfile[0]) {
- if (logt_logfile_fp)
+ if (logt_logfile_fp) {
fclose(logt_logfile_fp);
+ logt_logfile_fp = NULL;
+ }
logt_logfile_fp = fopen(logt_logfile, "a+");
if (logt_logfile_fp != NULL) {
fd = fileno(logt_logfile_fp);
fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
}
+ } else {
+ if (logt_logfile_fp) {
+ fclose(logt_logfile_fp);
+ logt_logfile_fp = NULL;
+ }
}
if (logt_mode & LOG_MODE_OUTPUT_SYSLOG) {
@@ -265,9 +272,10 @@ void logt_exit(void)
pthread_mutex_lock(&mutex);
/* close syslog + log file */
closelog();
- if (logt_logfile_fp)
+ if (logt_logfile_fp) {
fclose(logt_logfile_fp);
- logt_logfile_fp = NULL;
+ logt_logfile_fp = NULL;
+ }
/* clean up any pending log messages */
dropped = 0;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-01-27 6:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-27 6:32 cluster: STABLE3 - logt: don't hold fd open when not required Fabio M. Di Nitto
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).