From 6b5c9b1b8e0bad08efc3e3d37fef39bf3ab9c80d Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Tue, 2 May 2023 16:46:06 -0700 Subject: [PATCH] separate the bind & listen calls on the http backplane (#1988) --- service/OneService.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/service/OneService.cpp b/service/OneService.cpp index 2a6973497..73012380d 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1994,14 +1994,21 @@ public: fprintf(stderr, "%s", http_log(req, res).c_str()); }); #endif + if (_primaryPort==0) { + fprintf(stderr, "unable to determine local control port"); + exit(-1); + } + + if(!_controlPlane.bind_to_port("0.0.0.0", _primaryPort)) { + fprintf(stderr, "Error binding control plane to port %d\n", _primaryPort); + exit(-1); + } _serverThread = std::thread([&] { - if (_primaryPort==0) { - fprintf(stderr, "unable to determine local control port"); - exit(-1); - } fprintf(stderr, "Starting Control Plane...\n"); - _controlPlane.listen("0.0.0.0", _primaryPort); + if(!_controlPlane.listen_after_bind()) { + fprintf(stderr, "Error on listen_after_bind()\n"); + } fprintf(stderr, "Control Plane Stopped\n"); });