[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xorg-server: Changes to 'ubuntu'



 debian/changelog      |    8 ++++++++
 debian/local/xvfb-run |   35 +++++++++++++++++++++++++++++------
 2 files changed, 37 insertions(+), 6 deletions(-)

New commits:
commit b1386f484e79f845a4b5db78fbcdd7086d1c64a9
Author: Bryce Harrington <bryce@bryceharrington.org>
Date:   Wed Oct 14 15:25:13 2009 -0700

    Apply de-bashed patch for fixing xvfb concurrent invocations

diff --git a/debian/changelog b/debian/changelog
index 491b0ed..79cd4bb 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+xorg-server (2:1.6.4-2ubuntu3) karmic; urgency=low
+
+  * local/xvfb-run: Fix race condition in xvfb-run that can cause
+    concurrent invocations to fail.
+    (LP: #348052)
+
+ -- Bryce Harrington <bryce@ubuntu.com>  Wed, 14 Oct 2009 15:21:51 -0700
+
 xorg-server (2:1.6.4-2ubuntu2) karmic; urgency=low
 
   * Add 187_edid_quirk_hp_nc8430.patch: Quirk for another LPL monitor, to
diff --git a/debian/local/xvfb-run b/debian/local/xvfb-run
index 9e68fe3..b6156c5 100644
--- a/debian/local/xvfb-run
+++ b/debian/local/xvfb-run
@@ -110,7 +110,7 @@ eval set -- "$ARGS"
 
 while :; do
     case "$1" in
-        -a|--auto-servernum) SERVERNUM=$(find_free_servernum) ;;
+        -a|--auto-servernum) SERVERNUM=$(find_free_servernum); AUTONUM="yes" ;;
         -e|--error-file) ERRORFILE="$2"; shift ;;
         -f|--auth-file) AUTHFILE="$2"; shift ;;
         -h|--help) SHOWHELP="yes" ;;
@@ -153,13 +153,36 @@ if [ -z "$AUTHFILE" ]; then
 fi
 
 # Start Xvfb.
-MCOOKIE=$(mcookie)
-XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1
+tries=1000
+while test $tries -gt 0; do
+    tries=$((tries-1))
+    MCOOKIE=$(mcookie)
+    XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1
 add :$SERVERNUM $XAUTHPROTO $MCOOKIE
 EOF
-XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >>"$ERRORFILE" \
-  2>&1 &
-XVFBPID=$!
+    XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >>"$ERRORFILE" 2>&1 &
+    XVFBPID=$!
+
+    # Test PID of Xvfb and contents of the X server lock file
+    # (use numerical comparison to avoid whitespace issues).
+    # If the display was in use the Xvfb process will die on its own.
+    LOCKPID=`cat /tmp/.X${SERVERNUM}-lock)` 2>/dev/null
+    if [ -z $LOCKPID ]; then
+        break
+    fi
+    if [ "$XVFBPID" -eq $LOCKPID ]; then
+        break
+    fi
+    # The display is in use so try another one (if '-a' was specified).
+    if [ "$AUTONUM" ]; then
+        SERVERNUM=$(find_free_servernum)
+        continue
+    fi
+    error "display :$SERVERNUM already in use"
+    exit 1
+
+done
+
 sleep "$STARTWAIT"
 if ! kill -0 $XVFBPID 2>/dev/null; then
   echo "Xvfb failed to start" >&2


Reply to: