ovn-nbctl: Don't loop forever on lost db connection.
authorRussell Bryant <rbryant@redhat.com>
Tue, 31 Mar 2015 17:43:18 +0000 (13:43 -0400)
committerBen Pfaff <blp@nicira.com>
Tue, 31 Mar 2015 18:08:37 +0000 (11:08 -0700)
The main loop of ovn-nbctl had a condition to catch if the conenction
to the db was lost.  However, it didn't break out of the loop when the
condition occurred.  Now it should log the error once and exit with a
non-zero status code.

Signed-off-by: Russell Bryant <rbryant@redhat.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovn/ovn-nbctl.c

index b470e9f..3837341 100644 (file)
@@ -583,6 +583,7 @@ main(int argc, char *argv[])
     struct nbctl_context nb_ctx = { .idl = NULL, };
     enum ovsdb_idl_txn_status txn_status;
     unsigned int seqno;
+    int res = 0;
 
     fatal_ignore_sigpipe();
     set_program_name(argv[0]);
@@ -604,6 +605,8 @@ main(int argc, char *argv[])
             int retval = ovsdb_idl_get_last_error(nb_ctx.idl);
             VLOG_ERR("%s: database connection failed (%s)",
                     db, ovs_retval_to_string(retval));
+            res = 1;
+            break;
         }
 
         if (seqno != ovsdb_idl_get_seqno(nb_ctx.idl)) {
@@ -628,5 +631,5 @@ main(int argc, char *argv[])
     }
     ovsdb_idl_destroy(nb_ctx.idl);
 
-    exit(0);
+    exit(res);
 }