Skip to content

Commit 2c1b166

Browse files
committed
fix(mdns): Fix mdns_delegate_hostname_add() to block until done
Adds action semaphore the same way it's done in mdns_hostname_add() There could still potentially be a minor issue when calling these two APIs simultanously. Will solve the same ways as in 8a69050 (tracked as IDF-10913)
1 parent 169405b commit 2c1b166

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/mdns/mdns.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5211,6 +5211,7 @@ static void _mdns_execute_action(mdns_action_t *action)
52115211
free((char *)action->data.delegate_hostname.hostname);
52125212
free_address_list(action->data.delegate_hostname.address_list);
52135213
}
5214+
xSemaphoreGive(_mdns_server->action_sema);
52145215
break;
52155216
case ACTION_DELEGATE_HOSTNAME_SET_ADDR:
52165217
if (!_mdns_delegate_hostname_set_address(action->data.delegate_hostname.hostname,
@@ -5774,6 +5775,7 @@ esp_err_t mdns_delegate_hostname_add(const char *hostname, const mdns_ip_addr_t
57745775
free(action);
57755776
return ESP_ERR_NO_MEM;
57765777
}
5778+
xSemaphoreTake(_mdns_server->action_sema, portMAX_DELAY);
57775779
return ESP_OK;
57785780
}
57795781

@@ -5893,7 +5895,7 @@ esp_err_t mdns_service_add_for_host(const char *instance, const char *service, c
58935895
ESP_GOTO_ON_FALSE(_mdns_can_add_more_services(), ESP_ERR_NO_MEM, err, TAG, "Cannot add more services");
58945896

58955897
mdns_srv_item_t *item = _mdns_get_service_item_instance(instance, service, proto, hostname);
5896-
ESP_GOTO_ON_FALSE(!item, ESP_ERR_INVALID_ARG, err, TAG, "Already exists");
5898+
ESP_GOTO_ON_FALSE(!item, ESP_ERR_INVALID_ARG, err, TAG, "Service already exists");
58975899

58985900
s = _mdns_create_service(service, proto, hostname, port, instance, num_items, txt);
58995901
ESP_GOTO_ON_FALSE(s, ESP_ERR_NO_MEM, err, TAG, "Cannot create service: Out of memory");

0 commit comments

Comments
 (0)