summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2005-06-27 22:44:57 +0000
committerSimo Sorce <idra@samba.org>2005-06-27 22:44:57 +0000
commitae5191db2af44e280d8f3f2171c644812b057e65 (patch)
tree351ab4d667c803d672de32c4e065542e9544dde1
parent5c9476f8d12c13dec63ff51a04d47c49d3fe23aa (diff)
downloadsamba-ae5191db2af44e280d8f3f2171c644812b057e65.tar.gz
samba-ae5191db2af44e280d8f3f2171c644812b057e65.tar.xz
samba-ae5191db2af44e280d8f3f2171c644812b057e65.zip
r7961: randomize reloading so that smbds do not pverload cupsd
by reloading printers all at the same time. sss
-rw-r--r--source/smbd/process.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/smbd/process.c b/source/smbd/process.c
index 1ec176bd088..c4c1debbf38 100644
--- a/source/smbd/process.c
+++ b/source/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;