Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mdns): support zero item when update subtype (IDFGH-14369) #726

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/mdns/include/mdns.h
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ esp_err_t mdns_service_subtype_add_multiple_items_for_host(const char *instance_
* @param subtype the pointer of subtype array to add.
* @param num_items number of items in subtype array
*
* @note If `num_items` is 0, then remove all subtypes.
*
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
Expand Down
9 changes: 5 additions & 4 deletions components/mdns/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -6429,8 +6429,8 @@ esp_err_t mdns_service_subtype_update_multiple_items_for_host(const char *instan
MDNS_SERVICE_LOCK();
esp_err_t ret = ESP_OK;
int cur_index = 0;
ESP_GOTO_ON_FALSE(_mdns_server && _mdns_server->services && !_str_null_or_empty(service_type) && !_str_null_or_empty(proto) &&
(num_items > 0), ESP_ERR_INVALID_ARG, err, TAG, "Invalid state or arguments");
ESP_GOTO_ON_FALSE(_mdns_server && _mdns_server->services && !_str_null_or_empty(service_type) && !_str_null_or_empty(proto),
ESP_ERR_INVALID_ARG, err, TAG, "Invalid state or arguments");

mdns_srv_item_t *s = _mdns_get_service_item_instance(instance_name, service_type, proto, hostname);
ESP_GOTO_ON_FALSE(s, ESP_ERR_NOT_FOUND, err, TAG, "Service doesn't exist");
Expand All @@ -6450,8 +6450,9 @@ esp_err_t mdns_service_subtype_update_multiple_items_for_host(const char *instan
goto exit;
}
}

_mdns_announce_all_pcbs(&s, 1, false);
if (num_items) {
_mdns_announce_all_pcbs(&s, 1, false);
}
err:
if (ret == ESP_ERR_NO_MEM) {
for (int idx = 0; idx < cur_index; idx++) {
Expand Down
Loading