]> granicus.if.org Git - esp-idf/commitdiff
mdns: skip sending search when finished, not properly locked timer task
authorDavid Cermak <cermak@espressif.com>
Fri, 30 Nov 2018 16:00:05 +0000 (17:00 +0100)
committerDavid Cermak <cermak@espressif.com>
Fri, 21 Dec 2018 15:26:39 +0000 (16:26 +0100)
components/mdns/mdns.c

index f5d337a32ce23df1dda4d337ca47740af8109056..ff8df426eff7fa6e2afaa54c08b8de67338b2155 100644 (file)
@@ -3480,6 +3480,22 @@ static void _mdns_search_send_pcb(mdns_search_once_t * search, tcpip_adapter_if_
  */
 static void _mdns_search_send(mdns_search_once_t * search)
 {
+    mdns_search_once_t* queue = _mdns_server->search_once;
+    bool found = false;
+    // looking for this search in active searches
+    while (queue) {
+        if (queue == search) {
+            found = true;
+            break;
+        }
+        queue = queue->next;
+    }
+
+    if (!found) {
+        // no longer active -> skip sending this search
+        return;
+    }
+
     uint8_t i, j;
     for (i=0; i<TCPIP_ADAPTER_IF_MAX; i++) {
         for (j=0; j<MDNS_IP_PROTOCOL_MAX; j++) {
@@ -3822,12 +3838,13 @@ static void _mdns_scheduler_run()
  */
 static void _mdns_search_run()
 {
+    MDNS_SERVICE_LOCK();
     mdns_search_once_t * s = _mdns_server->search_once;
     uint32_t now = xTaskGetTickCount() * portTICK_PERIOD_MS;
     if (!s) {
+        MDNS_SERVICE_UNLOCK();
         return;
     }
-    MDNS_SERVICE_LOCK();
     while (s) {
         if (s->state != SEARCH_OFF) {
             if (now > (s->started_at + s->timeout)) {