diff mbox series

[4/9] wmediumd: init time controller connection later

Message ID 20200625150754.86118afacfc9.I314c0396c470f9368b46dc7a8758394e560f48ac@changeid
State New
Headers show
Series [1/9] wmediumd: add -lstdc++ for SANITIZE=1 | expand

Commit Message

Johannes Berg June 25, 2020, 1:08 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Some infrastructure that starts wmediumd might wait for it
to start up by checking the sockets it should offer exist,
yet have time stopped during startup for debug purposes.

Initialize the time connection later so that the startup
can happen regardless of such a scenario. Nothing can be
processed on any of the sockets until we actually get to
the mainloop anyway, so this is entirely safe.

---
 wmediumd/wmediumd.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/wmediumd/wmediumd.c b/wmediumd/wmediumd.c
index 0f45c75be9c9..d7ffd8396d8a 100644
--- a/wmediumd/wmediumd.c
+++ b/wmediumd/wmediumd.c
@@ -1181,18 +1181,6 @@  int main(int argc, char *argv[])
 		usfstl_sched_add_job(&scheduler, &ctx.intf_job);
 	}
 
-	if (time_socket) {
-		usfstl_sched_ctrl_start(&ctrl, time_socket,
-				      1000 /* nsec per usec */,
-				      (uint64_t)-1 /* no ID */,
-				      &scheduler);
-		vusrv.scheduler = &scheduler;
-		vusrv.ctrl = &ctrl;
-		ctx.ctrl = &ctrl;
-	} else {
-		usfstl_sched_wallclock_init(&scheduler, 1000);
-	}
-
 	if (vusrv.socket)
 		usfstl_vhost_user_server_start(&vusrv);
 
@@ -1213,6 +1201,18 @@  int main(int argc, char *argv[])
 	if (api_socket)
 		usfstl_uds_create(api_socket, wmediumd_api_connected, &ctx);
 
+	if (time_socket) {
+		usfstl_sched_ctrl_start(&ctrl, time_socket,
+				      1000 /* nsec per usec */,
+				      (uint64_t)-1 /* no ID */,
+				      &scheduler);
+		vusrv.scheduler = &scheduler;
+		vusrv.ctrl = &ctrl;
+		ctx.ctrl = &ctrl;
+	} else {
+		usfstl_sched_wallclock_init(&scheduler, 1000);
+	}
+
 	while (1) {
 		if (time_socket) {
 			usfstl_sched_next(&scheduler);