public inbox for cluster-cvs@sourceware.org help / color / mirror / Atom feed
From: "Fabio M. Di Nitto" <fabbione@fedoraproject.org> To: cluster-cvs-relay@redhat.com Subject: cluster: master - logt: don't hold fd open when not required Date: Tue, 27 Jan 2009 06:32:00 -0000 [thread overview] Message-ID: <20090127063226.69D5DC024D@lists.fedorahosted.org> (raw) Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=88ea8eac58662f32b22b011f80eaca2636a036c0 Commit: 88ea8eac58662f32b22b011f80eaca2636a036c0 Parent: 40f37f5d04fb741fb1e6bfc7792f41afa23e7b9a 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:32:11 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;
reply other threads:[~2009-01-27 6:32 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20090127063226.69D5DC024D@lists.fedorahosted.org \ --to=fabbione@fedoraproject.org \ --cc=cluster-cvs-relay@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).