ovs-sandbox: add delay before running ovs-vsctl
authorAndy Zhou <azhou@nicira.com>
Fri, 10 Apr 2015 19:53:26 +0000 (12:53 -0700)
committerAndy Zhou <azhou@nicira.com>
Tue, 14 Apr 2015 21:52:34 +0000 (14:52 -0700)
When running ovsdb-server under gdb, there is a race that ovs-vsctl
command can be called before ovsdb-server is fully launched. This will
cause ovs-vsctl to fail.  This patch fixes this by delay issuing
the ovs-vsctl command until ovsdb-server is fully launched.

Signed-off-by: Andy Zhou <azhou@nicira.com>
Acked-by: Russell Bryant <rbryant@redhat.com>
Acked-by: Ben Pfaff <blp@nicira.com>
tutorial/ovs-sandbox

index 251f021..ebee4a9 100755 (executable)
@@ -235,6 +235,18 @@ run ovsdb-tool create conf.db "$schema"
 rungdb $gdb_ovsdb ovsdb-server --detach --no-chdir --pidfile -vconsole:off --log-file \
     --remote=punix:"$sandbox"/db.sock
 
+#Add a small delay to allow ovsdb-server to launch.
+sleep 0.1
+
+#Wait for ovsdb-server to finish launching.
+if test ! -e "$sandbox"/db.sock; then
+    echo -n "Waiting for ovsdb-server to start..."
+    while test ! -e "$sandbox"/db.sock; do
+        sleep 1;
+    done
+    echo "  Done"
+fi
+
 # Initialize database.
 run ovs-vsctl --no-wait -- init