From 4ff15c319eb70396f2534fb8c165b7f71c58b311 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 28 Aug 2000 03:17:22 +0000 Subject: made reopen_logs() always re-open logs, not try and be smart about not re-opening in some circumstances. This fixes a problem where a HUP does not re-open logs and leaves the log open on a unlinked file. (This used to be commit f99f028c77482e591741df2a3da7f036f7409a68) --- source3/lib/debug.c | 71 +++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 37 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index a388956d42..bfb638a38a 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -195,48 +195,45 @@ void setup_logging( char *pname, BOOL interactive ) /* ************************************************************************** ** * reopen the log files + * note that we now do this unconditionally * ************************************************************************** ** */ void reopen_logs( void ) - { - pstring fname; - - if( DEBUGLEVEL > 0 ) - { - pstrcpy( fname, debugf ); - if( lp_loaded() && (*lp_logfile()) ) - pstrcpy( fname, lp_logfile() ); +{ + pstring fname; + mode_t oldumask; + + if (DEBUGLEVEL <= 0) { + if (dbf) { + (void)fclose(dbf); + dbf = NULL; + } + return; + } - if( !strcsequal( fname, debugf ) || !dbf || !file_exist( debugf, NULL ) ) - { - mode_t oldumask = umask( 022 ); + oldumask = umask( 022 ); + + pstrcpy(fname, debugf ); + if (lp_loaded() && (*lp_logfile())) + pstrcpy(fname, lp_logfile()); + + pstrcpy( debugf, fname ); + if (dbf) + (void)fclose(dbf); + if (append_log) + dbf = sys_fopen( debugf, "a" ); + else + dbf = sys_fopen( debugf, "w" ); + /* Fix from klausr@ITAP.Physik.Uni-Stuttgart.De + * to fix problem where smbd's that generate less + * than 100 messages keep growing the log. + */ + force_check_log_size(); + if (dbf) + setbuf( dbf, NULL ); + (void)umask(oldumask); +} - pstrcpy( debugf, fname ); - if( dbf ) - (void)fclose( dbf ); - if( append_log ) - dbf = sys_fopen( debugf, "a" ); - else - dbf = sys_fopen( debugf, "w" ); - /* Fix from klausr@ITAP.Physik.Uni-Stuttgart.De - * to fix problem where smbd's that generate less - * than 100 messages keep growing the log. - */ - force_check_log_size(); - if( dbf ) - setbuf( dbf, NULL ); - (void)umask( oldumask ); - } - } - else - { - if( dbf ) - { - (void)fclose( dbf ); - dbf = NULL; - } - } - } /* reopen_logs */ /* ************************************************************************** ** * Force a check of the log size. -- cgit