diff options
author | Andrew Tridgell <tridge@samba.org> | 2000-08-28 03:17:22 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2000-08-28 03:17:22 +0000 |
commit | 4ff15c319eb70396f2534fb8c165b7f71c58b311 (patch) | |
tree | a7b78229118ca3ec39fbb14bd2976ac3d117b284 | |
parent | bbc7918ad07c179729c41ed839a5a9afae91f2dc (diff) | |
download | samba-4ff15c319eb70396f2534fb8c165b7f71c58b311.tar.gz samba-4ff15c319eb70396f2534fb8c165b7f71c58b311.tar.bz2 samba-4ff15c319eb70396f2534fb8c165b7f71c58b311.zip |
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)
-rw-r--r-- | source3/lib/debug.c | 71 |
1 files changed, 34 insertions, 37 deletions
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. |