Add retry logic to rebaseall

David Boyce david.s.boyce@gmail.com
Thu Jan 16 04:23:00 GMT 2014


Jason et al,

Here's a suggested new flag (with patch, attached) for
/usr/bin/rebaseall. It adds a -w(ait) flag which causes the check for
running Cygwin processes to be done in a loop, breaking out and doing
the rebaseall as soon as it finds a quiescent moment.

We run Cygwin on build servers which are almost always busy. When they
need a rebase (which is rare with modern Cygwin but has happened) it's
hard to find a moment when things are quiet. Of course we can take a
server out of the queue, wait for builds to finish, rebase, and put it
back but that's a slow, manual process. Running "dash -c
'/usr/bin/rebaseall -w 10'" would tell it to try every 10 seconds
until it sees an opening, then go for it and exit.

Arguably, the flag should be -r (retry) but I'll leave that to you if accepted.
-------------- next part --------------
--- /bin/rebaseall	2013-12-03 16:28:03.000000000 -0800
+++ /bin/rebaseall.dsb	2014-01-09 09:51:12.338413000 -0800
@@ -29,7 +29,7 @@
 PATH=$(cd $tp2 && pwd):/usr/bin:/bin
 
 ProgramName=${0##*/}
-ProgramOptions='48b:o:ps:tT:v'
+ProgramOptions='48b:o:ps:tT:vw:'
 DefaultBaseAddress=0x70000000
 DefaultOffset=0
 DefaultTouch=
@@ -41,7 +41,7 @@
 # Define functions
 usage()
 {
-    echo "usage: ${ProgramName} [-b BaseAddress] [-o Offset] [-s DllSuffix] [-T FileList | -] [-4|-8] [-p] [-t] [-v]"
+    echo "usage: ${ProgramName} [-b BaseAddress] [-o Offset] [-s DllSuffix] [-T FileList | -] [-4|-8] [-p] [-t] [-v] [-w seconds]"
     exit 1
 }
 
@@ -60,6 +60,7 @@
 Touch="${DefaultTouch}"
 NoDyn="${DefaultNoDyn}"
 Verbose="${DefaultVerbose}"
+WaitSeconds=0
 FileList="${DefaultFileList}"
 Suffixes="${DefaultSuffixes}"
 db_file_i386="/etc/rebase.db.i386"
@@ -123,11 +124,15 @@
 	FileList="${OPTARG}";;
     v)
 	Verbose="-v";;
+    w)
+	WaitSeconds="${OPTARG}";;
     \?)
 	usage;;
     esac
 done
 
+while :
+do
 # Verify only ash or dash processes are running
 if [ "${check_for_dash_only}" != "no" ]
 then
@@ -160,15 +165,25 @@
       ProcessResult=$?
       ;;
   esac
-  if [ $ProcessResult -eq 0 -a -z "${RebaseDebug}" ]
+      # If none found, we're good to go.
+      if [ $ProcessResult -ne 0 -o -n "${RebaseDebug}" ]
+      then
+	  break
+      fi
+      # Otherwise either quit or wait and retry.
+      if [ $WaitSeconds -eq 0 ]
   then
       echo "${ProgramName}: only ash or dash processes are allowed during rebasing"
       echo "    Exit all Cygwin processes and stop all Cygwin services."
       echo "    Execute ash (or dash) from Start/Run... or a cmd or command window."
       echo "    Execute '/bin/rebaseall' from ash (or dash)."
       exit 2
+      else
+	  echo "${ProgramName}: Cygwin processes found, retry in $WaitSeconds seconds ..."
+	  sleep $WaitSeconds
   fi
 fi
+done
 
 # Check if rebase database already exists.
 database_exists="no"
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list