summaryrefslogtreecommitdiff
path: root/source3/smbd/process.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-06-27 22:44:57 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:58:05 -0500
commit7ebd74e6c502483b7f7c73943b698d6433c8c0b2 (patch)
treeb606307061107fc7a3f479ce1dd41e52898083f7 /source3/smbd/process.c
parent39605e52aa1e12eba0a758869333e17c99723de6 (diff)
downloadsamba-7ebd74e6c502483b7f7c73943b698d6433c8c0b2.tar.gz
samba-7ebd74e6c502483b7f7c73943b698d6433c8c0b2.tar.bz2
samba-7ebd74e6c502483b7f7c73943b698d6433c8c0b2.zip
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)
Diffstat (limited to 'source3/smbd/process.c')
-rw-r--r--source3/smbd/process.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 1ec176bd08..c4c1debbf3 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;