X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=vswitchd%2Fovs-brcompatd.c;h=62faaaa54c58eb21b39a7748ccd4bc2945b3b1b4;hb=975ac5313396fbafe829b862335d90967b4d74f3;hp=b7627e01ef1f59f5982c765b22ab67d5fe6a8423;hpb=9852694f9e9ac12868463094b894a1da61535a7f;p=openvswitch diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c index b7627e01..62faaaa5 100644 --- a/vswitchd/ovs-brcompatd.c +++ b/vswitchd/ovs-brcompatd.c @@ -75,10 +75,6 @@ static void usage(void) NO_RETURN; static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 60); -/* Maximum number of milliseconds to wait for the config file to be - * unlocked. If set to zero, no waiting will occur. */ -static int lock_timeout = 500; - /* Maximum number of milliseconds to wait before pruning port entries that * no longer exist. If set to zero, ports are never pruned. */ static int prune_timeout = 5000; @@ -1148,7 +1144,6 @@ main(int argc, char *argv[]) struct unixctl_server *unixctl; const char *remote; struct ovsdb_idl *idl; - unsigned int idl_seqno; int retval; set_program_name(argv[0]); @@ -1163,7 +1158,7 @@ main(int argc, char *argv[]) process_init(); die_if_already_running(); - daemonize(); + daemonize_start(); retval = unixctl_server_create(NULL, &unixctl); if (retval) { @@ -1181,39 +1176,30 @@ main(int argc, char *argv[]) } } + daemonize_complete(); + idl = ovsdb_idl_create(remote, &ovsrec_idl_class); - idl_seqno = ovsdb_idl_get_seqno(idl); for (;;) { const struct ovsrec_open_vswitch *ovs; struct ovsdb_idl_txn *txn; - int status; - unsigned int new_idl_seqno; + enum ovsdb_idl_txn_status status; ovsdb_idl_run(idl); - /* xxx Complete hack to get around bad ovs! */ - new_idl_seqno = ovsdb_idl_get_seqno(idl); - if (new_idl_seqno == idl_seqno) { - ovsdb_idl_wait(idl); - poll_block(); - printf("xxx trying again...\n"); - idl_seqno = new_idl_seqno; - continue; - } - - ovs = ovsrec_open_vswitch_first(idl); - if (!ovs) { - /* XXX it would be more user-friendly to create a record ourselves - * (while verifying that the table is empty before doing so). */ - ovs_fatal(0, "%s: database does not contain any Open vSwitch " - "configuration", remote); - } - txn = ovsdb_idl_txn_create(idl); unixctl_server_run(unixctl); - brc_recv_update(ovs); + ovs = ovsrec_open_vswitch_first(idl); + if (ovs) { + brc_recv_update(ovs); + } else if (ovsdb_idl_get_seqno(idl)) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1); + VLOG_WARN_RL(&rl, "%s: database does not contain any Open vSwitch " + "configuration", remote); + } else { + /* Haven't yet received initial database contents. */ + } netdev_run(); #if 0 @@ -1253,6 +1239,7 @@ main(int argc, char *argv[]) ovs_fatal(0, "transaction aborted"); case TXN_SUCCESS: + case TXN_UNCHANGED: break; case TXN_TRY_AGAIN: @@ -1305,7 +1292,6 @@ static const char * parse_options(int argc, char *argv[]) { enum { - OPT_LOCK_TIMEOUT = UCHAR_MAX + 1, OPT_PRUNE_TIMEOUT, OPT_APPCTL_COMMAND, VLOG_OPTION_ENUMS, @@ -1314,7 +1300,6 @@ parse_options(int argc, char *argv[]) static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"version", no_argument, 0, 'V'}, - {"lock-timeout", required_argument, 0, OPT_LOCK_TIMEOUT}, {"prune-timeout", required_argument, 0, OPT_PRUNE_TIMEOUT}, {"appctl-command", required_argument, 0, OPT_APPCTL_COMMAND}, DAEMON_LONG_OPTIONS, @@ -1342,10 +1327,6 @@ parse_options(int argc, char *argv[]) OVS_PRINT_VERSION(0, 0); exit(EXIT_SUCCESS); - case OPT_LOCK_TIMEOUT: - lock_timeout = atoi(optarg); - break; - case OPT_PRUNE_TIMEOUT: prune_timeout = atoi(optarg) * 1000; break; @@ -1390,7 +1371,6 @@ usage(void) printf("\nConfiguration options:\n" " --appctl-command=COMMAND shell command to run ovs-appctl\n" " --prune-timeout=SECS wait at most SECS before pruning ports\n" - " --lock-timeout=MSECS wait at most MSECS for CONFIG to unlock\n" ); daemon_usage(); vlog_usage();