[ovs-dev] [PATCH ovn] ovn-nbctl: Don't loop forever on lost db connection.

Ben Pfaff blp at nicira.com
Wed Apr 1 00:10:26 UTC 2015


On Tue, Mar 31, 2015 at 12:49:11PM -0500, Kyle Mestery wrote:
> On Tue, Mar 31, 2015 at 12:43 PM, Russell Bryant <rbryant at redhat.com> wrote:
> 
> > 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 at redhat.com>
> > ---
> >  ovn/ovn-nbctl.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/ovn/ovn-nbctl.c b/ovn/ovn-nbctl.c
> > index b470e9f..3837341 100644
> > --- a/ovn/ovn-nbctl.c
> > +++ b/ovn/ovn-nbctl.c
> > @@ -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);
> >  }
> > --
> > 2.1.0
> >
> > Looks fine to me.
> 
> Acked-by: Kyle Mestery <mestery at mestery.com>

Thanks for the review!  I forgot to apply your ack when I pushed that;
I apologize.


More information about the dev mailing list