Skip to content

Commit 2e03166

Browse files
fixup! fix(log_router): ensure mutex is created successfully, or else return an error
1 parent adb014e commit 2e03166

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

components/utilities/log_router/log_router.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,13 @@ static void esp_log_router_shutdown(void)
286286

287287
esp_err_t esp_log_router_to_file(const char* file_path, const char* tag, esp_log_level_t level)
288288
{
289-
// Create mutex for thread safety
290-
g_log_router_mutex = xSemaphoreCreateMutex();
289+
// Create mutex for thread safety, the first time we ran
291290
if (g_log_router_mutex == NULL) {
292-
ESP_LOGW(TAG, "Failed to create mutex for log router");
293-
return ESP_ERR_NO_MEM;
291+
g_log_router_mutex = xSemaphoreCreateMutex();
292+
if (g_log_router_mutex == NULL) {
293+
ESP_LOGE(TAG, "Failed to create mutex for log router");
294+
return ESP_ERR_NO_MEM;
295+
}
294296
}
295297

296298
if (!file_path) {

0 commit comments

Comments
 (0)