Skip to content

Commit

Permalink
fix(mdns): Fix mdns_delegate_hostname_add() to block until done
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
david-cermak committed Aug 19, 2024
1 parent 169405b commit 2c1b166
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion components/mdns/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -5211,6 +5211,7 @@ static void _mdns_execute_action(mdns_action_t *action)
free((char *)action->data.delegate_hostname.hostname);
free_address_list(action->data.delegate_hostname.address_list);
}
xSemaphoreGive(_mdns_server->action_sema);
break;
case ACTION_DELEGATE_HOSTNAME_SET_ADDR:
if (!_mdns_delegate_hostname_set_address(action->data.delegate_hostname.hostname,
Expand Down Expand Up @@ -5774,6 +5775,7 @@ esp_err_t mdns_delegate_hostname_add(const char *hostname, const mdns_ip_addr_t
free(action);
return ESP_ERR_NO_MEM;
}
xSemaphoreTake(_mdns_server->action_sema, portMAX_DELAY);
return ESP_OK;
}

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

mdns_srv_item_t *item = _mdns_get_service_item_instance(instance, service, proto, hostname);
ESP_GOTO_ON_FALSE(!item, ESP_ERR_INVALID_ARG, err, TAG, "Already exists");
ESP_GOTO_ON_FALSE(!item, ESP_ERR_INVALID_ARG, err, TAG, "Service already exists");

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

0 comments on commit 2c1b166

Please sign in to comment.