svn commit: samba r14038 - in branches/SAMBA_4_0/source: lib/util
smbd
metze at samba.org
metze at samba.org
Wed Mar 8 12:31:58 GMT 2006
Author: metze
Date: 2006-03-08 12:31:57 +0000 (Wed, 08 Mar 2006)
New Revision: 14038
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=14038
Log:
reopen log files after a SIGHUP
metze
Modified:
branches/SAMBA_4_0/source/lib/util/debug.c
branches/SAMBA_4_0/source/smbd/server.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/util/debug.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util/debug.c 2006-03-08 11:13:13 UTC (rev 14037)
+++ branches/SAMBA_4_0/source/lib/util/debug.c 2006-03-08 12:31:57 UTC (rev 14038)
@@ -47,11 +47,31 @@
const char *prog_name;
} state;
+static BOOL reopen_logs_scheduled;
+static BOOL check_reopen_logs(void)
+{
+ if (state.fd == 0 || reopen_logs_scheduled) {
+ reopen_logs_scheduled = False;
+ reopen_logs();
+ }
+
+ if (state.fd <= 0) return False;
+
+ return True;
+}
+
+_PUBLIC_ void debug_schedule_reopen_logs(void)
+{
+ reopen_logs_scheduled = True;
+}
+
static void log_timestring(int level, const char *location, const char *func)
{
char *t = NULL;
char *s = NULL;
+ if (!check_reopen_logs()) return;
+
if (state.logtype != DEBUG_FILE) return;
t = timestring(NULL, time(NULL));
@@ -87,12 +107,8 @@
va_list ap;
char *s = NULL;
- if (state.fd == 0) {
- reopen_logs();
- }
+ if (!check_reopen_logs()) return;
- if (state.fd <= 0) return;
-
va_start(ap, format);
vasprintf(&s, format, ap);
va_end(ap);
@@ -179,9 +195,9 @@
*/
_PUBLIC_ void log_suspicious_usage(const char *from, const char *info)
{
- if (debug_handlers.ops.log_suspicious_usage) {
- debug_handlers.ops.log_suspicious_usage(from, info);
- }
+ if (!debug_handlers.ops.log_suspicious_usage) return;
+
+ debug_handlers.ops.log_suspicious_usage(from, info);
}
@@ -190,9 +206,9 @@
*/
_PUBLIC_ void print_suspicious_usage(const char* from, const char* info)
{
- if (debug_handlers.ops.print_suspicious_usage) {
- debug_handlers.ops.print_suspicious_usage(from, info);
- }
+ if (!debug_handlers.ops.print_suspicious_usage) return;
+
+ debug_handlers.ops.print_suspicious_usage(from, info);
}
_PUBLIC_ uint32_t get_task_id(void)
@@ -205,9 +221,11 @@
_PUBLIC_ void log_task_id(void)
{
- if (debug_handlers.ops.log_task_id) {
- debug_handlers.ops.log_task_id(state.fd);
- }
+ if (!debug_handlers.ops.log_task_id) return;
+
+ if (!check_reopen_logs()) return;
+
+ debug_handlers.ops.log_task_id(state.fd);
}
/**
Modified: branches/SAMBA_4_0/source/smbd/server.c
===================================================================
--- branches/SAMBA_4_0/source/smbd/server.c 2006-03-08 11:13:13 UTC (rev 14037)
+++ branches/SAMBA_4_0/source/smbd/server.c 2006-03-08 12:31:57 UTC (rev 14038)
@@ -98,6 +98,11 @@
talloc_free(mem_ctx);
}
+static void sig_hup(int sig)
+{
+ debug_schedule_reopen_logs();
+}
+
/*
setup signal masks
*/
@@ -124,9 +129,7 @@
BlockSignals(False, SIGHUP);
BlockSignals(False, SIGTERM);
- /* as we don't handle on this signals yet, we need to ignore them,
- * instead of terminating */
- CatchSignal(SIGHUP, SIG_IGN);
+ CatchSignal(SIGHUP, sig_hup);
}
/*
More information about the samba-cvs
mailing list