From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8369 invoked by alias); 27 Jan 2009 06:32:48 -0000 Received: (qmail 8362 invoked by alias); 27 Jan 2009 06:32:48 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_52,KAM_MX,SPF_HELO_PASS X-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_52,KAM_MX,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.4 (2008-01-01) on bastion.fedora.phx.redhat.com Subject: cluster: master - logt: don't hold fd open when not required To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/master X-Git-Reftype: branch X-Git-Oldrev: 40f37f5d04fb741fb1e6bfc7792f41afa23e7b9a X-Git-Newrev: 88ea8eac58662f32b22b011f80eaca2636a036c0 From: "Fabio M. Di Nitto" Message-Id: <20090127063226.69D5DC024D@lists.fedorahosted.org> Date: Tue, 27 Jan 2009 06:32:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q1/txt/msg00285.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=88ea8eac58662f32b22b011f80eaca2636a036c0 Commit: 88ea8eac58662f32b22b011f80eaca2636a036c0 Parent: 40f37f5d04fb741fb1e6bfc7792f41afa23e7b9a Author: Fabio M. Di Nitto AuthorDate: Tue Jan 27 07:07:18 2009 +0100 Committer: Fabio M. Di Nitto 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 --- 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;