BcastListener: Guard start() w/spinlock for races
This commit is contained in:
@@ -133,10 +133,15 @@ void BroadcastListener::start(void)
|
|||||||
* We should also set up a timer to check for devices that have gone
|
* We should also set up a timer to check for devices that have gone
|
||||||
* away.
|
* 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
|
// Start the first async receive operation
|
||||||
startReceive();
|
startReceive();
|
||||||
std::cout << __func__ << ": BroadcastListener started on port "
|
std::cout << __func__ << ": BroadcastListener started on port "
|
||||||
|
|||||||
Reference in New Issue
Block a user