diff mbox series

[ovs-dev,10/15] ovn-nbctl: Introduce a poll_timer based wait timeout.

Message ID 20180711192717.21409-11-jkbs@redhat.com
State Superseded
Headers show
Series Daemon mode for ovn-nbctl | expand

Commit Message

Jakub Sitnicki July 11, 2018, 7:27 p.m. UTC
Extend the main loop and the command runner so that the caller can
specify a timeout for poll_block(). This will allow us to break out of
the main loop when waiting on IDL, like in the blocked '--wait=sb/hv
sync' case.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
---
 ovn/utilities/ovn-nbctl.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

--
2.14.4

Comments

0-day Robot July 11, 2018, 8:02 p.m. UTC | #1
Bleep bloop.  Greetings Jakub Sitnicki, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


build:
depbase=`echo utilities/ovs-dpctl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu99 -DHAVE_CONFIG_H -I.    -I ./include -I ./include -I ./lib -I ./lib    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror -MT utilities/ovs-dpctl.o -MD -MP -MF $depbase.Tpo -c -o utilities/ovs-dpctl.o utilities/ovs-dpctl.c &&\
mv -f $depbase.Tpo $depbase.Po
/bin/sh ./libtool  --tag=CC   --mode=link gcc -std=gnu99 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror     -o utilities/ovs-dpctl utilities/ovs-dpctl.o lib/libopenvswitch.la -lpthread -lrt -lm  -lunbound
libtool: link: gcc -std=gnu99 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow -Werror -o utilities/ovs-dpctl utilities/ovs-dpctl.o  lib/.libs/libopenvswitch.a -lssl -lcrypto -lcap-ng -lpthread -lrt -lm -lunbound
depbase=`echo utilities/ovs-ofctl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu99 -DHAVE_CONFIG_H -I.    -I ./include -I ./include -I ./lib -I ./lib    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror -MT utilities/ovs-ofctl.o -MD -MP -MF $depbase.Tpo -c -o utilities/ovs-ofctl.o utilities/ovs-ofctl.c &&\
mv -f $depbase.Tpo $depbase.Po
/bin/sh ./libtool  --tag=CC   --mode=link gcc -std=gnu99 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror     -o utilities/ovs-ofctl utilities/ovs-ofctl.o ofproto/libofproto.la lib/libopenvswitch.la -lpthread -lrt -lm  -lunbound
libtool: link: gcc -std=gnu99 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow -Werror -o utilities/ovs-ofctl utilities/ovs-ofctl.o  ofproto/.libs/libofproto.a /var/lib/jenkins/jobs/upstream_build_from_pw/workspace/lib/.libs/libsflow.a lib/.libs/libopenvswitch.a -lssl -lcrypto -lcap-ng -lpthread -lrt -lm -lunbound
depbase=`echo utilities/ovs-vsctl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu99 -DHAVE_CONFIG_H -I.    -I ./include -I ./include -I ./lib -I ./lib    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror -MT utilities/ovs-vsctl.o -MD -MP -MF $depbase.Tpo -c -o utilities/ovs-vsctl.o utilities/ovs-vsctl.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from utilities/ovs-vsctl.c:49:0:
./lib/table.h:86:13: error: initializer element is not constant
     (struct table_style) { TF_LIST, CF_STRING, true, JSSF_SORT, 0 }
             ^
utilities/ovs-vsctl.c:85:41: note: in expansion of macro ‘TABLE_STYLE_DEFAULT’
 static struct table_style table_style = TABLE_STYLE_DEFAULT;
                                         ^
make[2]: *** [utilities/ovs-vsctl.o] Error 1
make[2]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace'
make: *** [all] Error 2


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 154e7799a..7f83abc40 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -37,6 +37,7 @@ 
 #include "svec.h"
 #include "table.h"
 #include "timeval.h"
+#include "timer.h"
 #include "util.h"
 #include "openvswitch/vlog.h"

@@ -87,13 +88,16 @@  static char * OVS_WARN_UNUSED_RESULT run_prerequisites(struct ctl_command[],
                                                        struct ovsdb_idl *);
 static char * OVS_WARN_UNUSED_RESULT do_nbctl(const char *args,
                                               struct ctl_command *, size_t n,
-                                              struct ovsdb_idl *, bool *retry);
+                                              struct ovsdb_idl *,
+                                              const struct timer *,
+                                              bool *retry);
 static const struct nbrec_dhcp_options *dhcp_options_get(
     struct ctl_context *ctx, const char *id, bool must_exist);
 static char * OVS_WARN_UNUSED_RESULT main_loop(const char *args,
                                                struct ctl_command *commands,
                                                size_t n_commands,
-                                               struct ovsdb_idl *idl);
+                                               struct ovsdb_idl *idl,
+                                               const struct timer *);

 int
 main(int argc, char *argv[])
@@ -132,7 +136,7 @@  main(int argc, char *argv[])
         ctl_fatal("%s", error);
     }

-    error = main_loop(args, commands, n_commands, idl);
+    error = main_loop(args, commands, n_commands, idl, NULL);
     if (error) {
         ctl_fatal("%s", error);
     }
@@ -153,7 +157,7 @@  main(int argc, char *argv[])

 static char *
 main_loop(const char *args, struct ctl_command *commands, size_t n_commands,
-          struct ovsdb_idl *idl)
+          struct ovsdb_idl *idl, const struct timer *wait_timeout)
 {
     unsigned int seqno;

@@ -177,7 +181,8 @@  main_loop(const char *args, struct ctl_command *commands, size_t n_commands,
             seqno = ovsdb_idl_get_seqno(idl);

             bool retry;
-            char *error = do_nbctl(args, commands, n_commands, idl, &retry);
+            char *error = do_nbctl(args, commands, n_commands, idl,
+                                   wait_timeout, &retry);
             if (error) {
                 return error;
             }
@@ -4159,7 +4164,7 @@  run_prerequisites(struct ctl_command *commands, size_t n_commands,

 static char *
 do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
-         struct ovsdb_idl *idl, bool *retry)
+         struct ovsdb_idl *idl, const struct timer *wait_timeout, bool *retry)
 {
     struct ovsdb_idl_txn *txn;
     enum ovsdb_idl_txn_status status;
@@ -4286,8 +4291,6 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
         OVS_NOT_REACHED();
     }

-    ovsdb_symbol_table_destroy(symtab);
-
     for (c = commands; c < &commands[n_commands]; c++) {
         struct ds *ds = &c->output;

@@ -4331,11 +4334,19 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
                 }
             }
             ovsdb_idl_wait(idl);
+            if (wait_timeout) {
+                timer_wait(wait_timeout);
+            }
             poll_block();
+            if (wait_timeout && timer_expired(wait_timeout)) {
+                error = xstrdup("timeout expired");
+                goto out_error;
+            }
         }
     done: ;
     }

+    ovsdb_symbol_table_destroy(symtab);
     ovsdb_idl_txn_destroy(txn);

     *retry = false;