diff options
author | Jeremy Allison <jra@samba.org> | 1998-07-23 00:10:26 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 1998-07-23 00:10:26 +0000 |
commit | 06c0349c445958aebb8a4611bdb7082711585754 (patch) | |
tree | 68c22e9d853aa0f77717b519abb4832a52331f55 /source3/lib | |
parent | f5866fd4ba8da9acde87c7f9da8f1a242540e287 (diff) | |
download | samba-06c0349c445958aebb8a4611bdb7082711585754.tar.gz samba-06c0349c445958aebb8a4611bdb7082711585754.tar.bz2 samba-06c0349c445958aebb8a4611bdb7082711585754.zip |
locking.c: Added lock type to is_locked() and do_lock()
as the code in reply_lockingX wasn't taking account of
the difference between read and write locks ! How did this
ever work :-) !
reply.c:
server.c: Add lock type to is_locked() and do_lock().
util.c: Also added code from klausr@ITAP.Physik.Uni-Stuttgart.De
to fix problem with log files growing too large if an
smbd writes less than 100 debug messages.
Jeremy.
(This used to be commit 80080abf772a470d5f0f4dcd4a75fb2a09a9fb2a)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/util.c | 81 |
1 files changed, 54 insertions, 27 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c index ec12affe79..22db8d4ab6 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -184,55 +184,82 @@ void reopen_logs(void) pstring fname; if (DEBUGLEVEL > 0) - { - pstrcpy(fname,debugf); - if (lp_loaded() && (*lp_logfile())) - pstrcpy(fname,lp_logfile()); + { + pstrcpy(fname,debugf); + if (lp_loaded() && (*lp_logfile())) + pstrcpy(fname,lp_logfile()); - if (!strcsequal(fname,debugf) || !dbf || !file_exist(debugf,NULL)) - { - int oldumask = umask(022); - pstrcpy(debugf,fname); - if (dbf) fclose(dbf); - if (append_log) - dbf = fopen(debugf,"a"); - else - dbf = fopen(debugf,"w"); - if (dbf) setbuf(dbf,NULL); - umask(oldumask); - } + if (!strcsequal(fname,debugf) || !dbf || !file_exist(debugf,NULL)) + { + int oldumask = umask(022); + pstrcpy(debugf,fname); + if (dbf) + fclose(dbf); + if (append_log) + dbf = fopen(debugf,"a"); + else + dbf = 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); + umask(oldumask); } + } else + { + if (dbf) { - if (dbf) - { - fclose(dbf); - dbf = NULL; - } + fclose(dbf); + dbf = NULL; } + } } +/******************************************************************* + Number of debug messages that have been output. + Used to check log size. +********************************************************************/ + +static int debug_count=0; + +/******************************************************************* + Force a check of the log size. +********************************************************************/ + +void force_check_log_size(void) +{ + debug_count = 100; +} /******************************************************************* -check if the log has grown too big + Check if the log has grown too big ********************************************************************/ + static void check_log_size(void) { - static int debug_count=0; int maxlog; struct stat st; - if (debug_count++ < 100 || getuid() != 0) return; + if (debug_count++ < 100 || getuid() != 0) + return; maxlog = lp_max_log_size() * 1024; - if (!dbf || maxlog <= 0) return; + if (!dbf || maxlog <= 0) + return; if (fstat(fileno(dbf),&st) == 0 && st.st_size > maxlog) { - fclose(dbf); dbf = NULL; + fclose(dbf); + dbf = NULL; reopen_logs(); if (dbf && file_size(debugf) > maxlog) { pstring name; - fclose(dbf); dbf = NULL; + fclose(dbf); + dbf = NULL; slprintf(name,sizeof(name)-1,"%s.old",debugf); rename(debugf,name); reopen_logs(); |