Skip to content

Commit 3fc26a5

Browse files
authored
Merge pull request #780 from david-cermak/fix/mdns_task_delete_race
[mdns]: Fix potential task delete race
2 parents 2e28774 + 5db6be7 commit 3fc26a5

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

common_components/linux_compat/freertos/freertos_linux.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ void vTaskDelete(TaskHandle_t *task)
166166

167167
if (task == NULL) {
168168
pthread_exit(0);
169+
} else {
170+
pthread_cancel((pthread_t)task);
169171
}
170172
void *thread_rval = NULL;
171173
pthread_join((pthread_t)task, &thread_rval);

components/mdns/.cz.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ commitizen:
33
bump_message: 'bump(mdns): $current_version -> $new_version'
44
pre_bump_hooks: python ../../ci/changelog.py mdns
55
tag_format: mdns-v$version
6-
version: 1.8.0
6+
version: 1.8.1
77
version_files:
88
- idf_component.yml

components/mdns/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [1.8.1](https://github.com/espressif/esp-protocols/commits/mdns-v1.8.1)
4+
5+
### Bug Fixes
6+
7+
- Fix potential task delete race ([8ca45f34](https://github.com/espressif/esp-protocols/commit/8ca45f34))
8+
39
## [1.8.0](https://github.com/espressif/esp-protocols/commits/mdns-v1.8.0)
410

511
### Features

components/mdns/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: "1.8.0"
1+
version: "1.8.1"
22
description: "Multicast UDP service used to provide local network service and host discovery."
33
url: "https://github.com/espressif/esp-protocols/tree/master/components/mdns"
44
issues: "https://github.com/espressif/esp-protocols/issues"

components/mdns/mdns.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5427,7 +5427,7 @@ static void _mdns_service_task(void *pvParameters)
54275427
}
54285428
}
54295429
_mdns_service_task_handle = NULL;
5430-
vTaskDelete(NULL);
5430+
vTaskDelay(portMAX_DELAY);
54315431
}
54325432

54335433
static void _mdns_timer_cb(void *arg)
@@ -5532,16 +5532,17 @@ static esp_err_t _mdns_service_task_stop(void)
55325532
{
55335533
_mdns_stop_timer();
55345534
if (_mdns_service_task_handle) {
5535+
TaskHandle_t task_handle = _mdns_service_task_handle;
55355536
mdns_action_t action;
55365537
mdns_action_t *a = &action;
55375538
action.type = ACTION_TASK_STOP;
55385539
if (xQueueSend(_mdns_server->action_queue, &a, (TickType_t)0) != pdPASS) {
5539-
vTaskDelete(_mdns_service_task_handle);
55405540
_mdns_service_task_handle = NULL;
55415541
}
55425542
while (_mdns_service_task_handle) {
55435543
vTaskDelay(10 / portTICK_PERIOD_MS);
55445544
}
5545+
vTaskDelete(task_handle);
55455546
}
55465547
vSemaphoreDelete(_mdns_service_semaphore);
55475548
_mdns_service_semaphore = NULL;

0 commit comments

Comments
 (0)