--- a/src/um/update-refresh.sh Tue Jun 16 20:45:12 2009 -0500
+++ b/src/um/update-refresh.sh Wed Jun 17 16:27:00 2009 +0100
@@ -45,6 +45,11 @@
#
# ##########################################################################
+# Wait a random part of 30 minutes so servers do not get hit all at once
+let dither=1800*$RANDOM
+let dither=dither/32767
+sleep $dither
+
# Refresh the IPS catalog
fmri=svc:/application/pkg/update
image_dir=`svcprop -p update/image_dir $fmri`
@@ -246,4 +251,4 @@
if install; then
debug "Installed: $FILE to $CACHE_DIR/$UNPACKED_DIR"
fi
-fi
\ No newline at end of file
+fi
--- a/src/updatemanagernotifier.py Tue Jun 16 20:45:12 2009 -0500
+++ b/src/updatemanagernotifier.py Wed Jun 17 16:27:00 2009 +0100
@@ -31,6 +31,7 @@
import locale
import gettext
import getopt
+import random
try:
import gobject
gobject.threads_init()
@@ -128,7 +129,7 @@
self.pr = progress.NullProgressTracker()
if self.get_show_icon_on_startup():
self.client.set_bool(SHOW_ICON_ON_STARTUP_PREFERENCES, False)
- gobject.idle_add(self.check_for_updates)
+ self.schedule_check_for_updates()
else:
gobject.idle_add(self.do_next_check)
return False
@@ -210,8 +211,6 @@
return 0
def set_last_check_time(self):
- self.last_check_time = time.time()
-
try:
os.makedirs(LASTCHECK_DIR_NAME)
except os.error, eargs:
@@ -266,6 +265,15 @@
self.client.set_bool(SHOW_ICON_ON_STARTUP_PREFERENCES, value)
self.status_icon.set_visible(value)
+ def schedule_check_for_updates(self):
+ self.last_check_time = time.time()
+ # Add random delay so that servers will not be hit
+ # all at once
+ random_delay = random.randint(0, 1800)
+ if debug:
+ print "random_delay in do_next_check", random_delay
+ gobject.timeout_add(random_delay * 1000, self.check_for_updates)
+
def check_for_updates(self):
image_directory = os.popen(IMAGE_DIR_COMMAND).readline().rstrip()
if debug == True:
@@ -398,7 +406,7 @@
print "time for check: %f - %f \n" % (time.time(), \
self.last_check_time)
if self.is_check_required():
- gobject.idle_add(self.check_for_updates)
+ self.schedule_check_for_updates()
else:
self.schedule_next_check_for_checks()
return False