From 7ebd74e6c502483b7f7c73943b698d6433c8c0b2 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 27 Jun 2005 22:44:57 +0000 Subject: [PATCH] r7961: randomize reloading so that smbds do not pverload cupsd by reloading printers all at the same time. sss (This used to be commit da227d5f4311c84a12a4e2a9fd510328268af4b3) --- source3/smbd/process.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 1ec176bd088..c4c1debbf38 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1299,6 +1299,7 @@ static int setup_select_timeout(void) void check_reload(int t) { + static pid_t mypid = 0; static time_t last_smb_conf_reload_time = 0; static time_t last_printer_reload_time = 0; time_t printcap_cache_time = (time_t)lp_printcap_cache_time(); @@ -1314,6 +1315,15 @@ void check_reload(int t) last_printer_reload_time = t; } + if (mypid != getpid()) { /* First time or fork happened meanwhile */ + /* randomize over 60 second the printcap reload to avoid all + * process hitting cupsd at the same time */ + int time_range = 60; + + last_printer_reload_time += random() % time_range; + mypid = getpid(); + } + if (reload_after_sighup || (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK)) { reload_services(True); reload_after_sighup = False; -- 2.11.4.GIT