From e0c0976e0bdbdd5bdb118b9858b56c9d1226f1c7 Mon Sep 17 00:00:00 2001 From: Hayodea Hekol Date: Fri, 7 Nov 2025 21:12:05 -0400 Subject: [PATCH] BcastListener: Guard start() w/spinlock for races --- commonLibs/livoxProto1/broadcastListener.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/commonLibs/livoxProto1/broadcastListener.cpp b/commonLibs/livoxProto1/broadcastListener.cpp index 87c8f08..f11112a 100644 --- a/commonLibs/livoxProto1/broadcastListener.cpp +++ b/commonLibs/livoxProto1/broadcastListener.cpp @@ -133,10 +133,15 @@ void BroadcastListener::start(void) * We should also set up a timer to check for devices that have gone * away. */ - socket.open(boost::asio::ip::udp::v4()); - socket.bind(listeningEndpoint); + { + smo::SpinLock::Guard lock(isListeningLock); + + socket.open(boost::asio::ip::udp::v4()); + socket.bind(listeningEndpoint); + + isListening = true; + } - isListening = true; // Start the first async receive operation startReceive(); std::cout << __func__ << ": BroadcastListener started on port "