From 5aba426b98c8a9c252d7298d3d6e55b51090ceb8 Mon Sep 17 00:00:00 2001 From: Philippe G Date: Sun, 30 Aug 2020 12:30:30 -0700 Subject: [PATCH] no mutex needed for polling - release --- components/squeezelite/stream.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/squeezelite/stream.c b/components/squeezelite/stream.c index 83ae4b07..34897d5f 100644 --- a/components/squeezelite/stream.c +++ b/components/squeezelite/stream.c @@ -199,7 +199,6 @@ static void *stream_thread() { } else { - polling = true; pollinfo.fd = fd; pollinfo.events = POLLIN; if (stream.state == SEND_HEADERS) { @@ -208,6 +207,8 @@ static void *stream_thread() { } UNLOCK; + // no mutex needed - we just want to know if we are inside poll() + polling = true; if (_poll(ssl, &pollinfo, 100)) { @@ -364,7 +365,6 @@ static void *stream_thread() { UNLOCK; } else { - // it is safe to set it unlocked polling = false; LOG_SDEBUG("poll timeout"); } @@ -490,8 +490,7 @@ void stream_sock(u32_t ip, u16_t port, const char *header, size_t header_len, un #if EMBEDDED // wait till we are not polling anymore - for (LOCK; running && polling; UNLOCK, usleep(10000), LOCK); - UNLOCK; + while (polling && running) { usleep(10000); } #endif int sock = socket(AF_INET, SOCK_STREAM, 0);