[ovs-dev] [PATCH] ovsdb-tool: Don't wait for lockfiles on "compact" or "convert".

Ben Pfaff blp at nicira.com
Wed Jun 9 18:24:12 UTC 2010


Until now, "ovsdb-tool convert" and "ovsdb-tool compact" were willing to
wait an arbitrarily long time to get a lock on the database or on a
temporary file.  In practice, though, the program most likely to have the
lock is ovsdb-server, which is not a transient process, and thus
ovsdb-tool will likely wait indefinitely if it waits at all.

This commit changes these ovsdb-tool commands so that they won't wait at
all if some other program has the lock.  (The other commands already had
this behavior.)

As a side effect, this change fixes the behavior of
"/etc/init.d/openvswitch start" when Open vSwitch was already running.
Previously, it would hang waiting for "ovsdb-tool convert" to finish.
Now, it completes quickly with an error.

CC: Reid Price <reid at nicira.com>
Bug #2864.
---
 ovsdb/ovsdb-tool.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c
index 1c9e920..a68e0f9 100644
--- a/ovsdb/ovsdb-tool.c
+++ b/ovsdb/ovsdb-tool.c
@@ -189,7 +189,7 @@ compact_or_convert(const char *src_name, const char *dst_name,
 
     /* Lock the source, if we will be replacing it. */
     if (in_place) {
-        retval = lockfile_lock(src_name, INT_MAX, &src_lock);
+        retval = lockfile_lock(src_name, 0, &src_lock);
         if (retval) {
             ovs_fatal(retval, "%s: failed to lock lockfile", src_name);
         }
@@ -199,7 +199,7 @@ compact_or_convert(const char *src_name, const char *dst_name,
     if (in_place) {
         dst_name = xasprintf("%s.tmp", src_name);
     }
-    retval = lockfile_lock(dst_name, INT_MAX, &dst_lock);
+    retval = lockfile_lock(dst_name, 0, &dst_lock);
     if (retval) {
         ovs_fatal(retval, "%s: failed to lock lockfile", dst_name);
     }
-- 
1.7.1





More information about the dev mailing list