about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--Functions/Calendar/calendar_lockfiles8
2 files changed, 10 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index fa3e28269..7118464a3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-07-06  Peter Stephenson  <pws@csr.com>
+
+	* unposted: Functions/Calendar/calendar_lockfiles: configuration
+	appears to reduce collisions between lock attempts in multiple
+	windows.
+
 2007-07-05  Clint Adams  <clint@zsh.org>
 
 	* 23655: Completion/Unix/Command/_git: merge in git instaweb
diff --git a/Functions/Calendar/calendar_lockfiles b/Functions/Calendar/calendar_lockfiles
index 054b3f74b..93fbce060 100644
--- a/Functions/Calendar/calendar_lockfiles
+++ b/Functions/Calendar/calendar_lockfiles
@@ -3,13 +3,13 @@
 
 local file lockfile msgdone
 # Number of attempts to lock a file.  Probably not worth stylising.
-integer lockattempts=3 loadtried
+integer lockattempts=4 loadtried
 
 # The lockfile name is not stylised: it has to be a fixed
 # derivative of the main fail.
 for file; do
   lockfile=$file.lockfile
-  for (( i = 0; i < lockattempts; i++ )); do
+  for (( i = 0; i <= lockattempts; i++ )); do
     if ln -s $file $lockfile >/dev/null 2>&1; then
       lockfiles+=($lockfile)
       break
@@ -24,10 +24,10 @@ for file; do
     fi
     if zmodload -e zsh/zselect; then
       # This gives us finer grained timing (100th second).
-      # Randomize the sleep between .1 and 1 second so that
+      # Randomize the sleep between .1 and 2 seconds so that
       # we are much less likely to have multiple instances
       # retrying at once.
-      zselect -t $(( 10 + RANDOM * 90 / 32768 ))
+      zselect -t $(( 10 + RANDOM * 190 / 32768 ))
     else
       sleep 1
     fi