X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ovsdb%2Fovsdb-server.c;h=b86a504b57fe1f1c5ce781f6d9c7d200a3055628;hb=141f49423d7433b2a82b0de2d101f2dc6e6dbac9;hp=f63081369183245a169e93bd27837249e6a1a43d;hpb=58fda1dab104041fc693032475ec4662c1a52849;p=openvswitch diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c index f6308136..b86a504b 100644 --- a/ovsdb/ovsdb-server.c +++ b/ovsdb/ovsdb-server.c @@ -44,8 +44,6 @@ #include "vlog.h" #define THIS_MODULE VLM_ovsdb_server -static const struct jsonrpc_server_cbs ovsdb_jsonrpc_cbs; - static unixctl_cb_func ovsdb_server_exit; static void parse_options(int argc, char *argv[], char **file_namep, @@ -60,6 +58,7 @@ main(int argc, char *argv[]) struct unixctl_server *unixctl; struct ovsdb_jsonrpc_server *jsonrpc; struct svec active, passive; + struct pstream **listeners; struct ovsdb_error *error; struct ovsdb *db; const char *name; @@ -78,6 +77,18 @@ main(int argc, char *argv[]) parse_options(argc, argv, &file_name, &active, &passive, &unixctl_path); + /* Open all the passive sockets before detaching, to avoid race with + * processes that start up later. */ + listeners = xmalloc(passive.n * sizeof *listeners); + for (i = 0; i < passive.n; i++) { + int error; + + error = pstream_open(passive.names[i], &listeners[i]); + if (error) { + ovs_fatal(error, "failed to listen on \"%s\"", passive.names[i]); + } + } + if (get_detach() && is_chdir_enabled()) { /* We need to skip chdir("/") in daemonize() and do it later, because * we need to open the database and possible set up up Unix domain @@ -101,11 +112,8 @@ main(int argc, char *argv[]) SVEC_FOR_EACH (i, name, &active) { ovsdb_jsonrpc_server_connect(jsonrpc, name); } - SVEC_FOR_EACH (i, name, &passive) { - retval = ovsdb_jsonrpc_server_listen(jsonrpc, name); - if (retval) { - ovs_fatal(retval, "failed to listen on %s", name); - } + for (i = 0; i < passive.n; i++) { + ovsdb_jsonrpc_server_listen(jsonrpc, listeners[i]); } svec_destroy(&active); svec_destroy(&passive);