Fix race in log_printf (#5523)
Fixes: https://github.com/espressif/arduino-esp32/issues/5513 Can still race if Serial.begin() is not called in setup()
This commit is contained in:
parent
5fd737925f
commit
0b0dfab3cf
@ -648,17 +648,19 @@ int log_printf(const char *format, ...)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vsnprintf(temp, len+1, format, arg);
|
|
||||||
#if !CONFIG_DISABLE_HAL_LOCKS
|
#if !CONFIG_DISABLE_HAL_LOCKS
|
||||||
if(s_uart_debug_nr != -1 && _uart_bus_array[s_uart_debug_nr].lock){
|
if(s_uart_debug_nr != -1 && _uart_bus_array[s_uart_debug_nr].lock){
|
||||||
xSemaphoreTake(_uart_bus_array[s_uart_debug_nr].lock, portMAX_DELAY);
|
xSemaphoreTake(_uart_bus_array[s_uart_debug_nr].lock, portMAX_DELAY);
|
||||||
ets_printf("%s", temp);
|
|
||||||
xSemaphoreGive(_uart_bus_array[s_uart_debug_nr].lock);
|
|
||||||
} else {
|
|
||||||
ets_printf("%s", temp);
|
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
|
vsnprintf(temp, len+1, format, arg);
|
||||||
ets_printf("%s", temp);
|
ets_printf("%s", temp);
|
||||||
|
|
||||||
|
#if !CONFIG_DISABLE_HAL_LOCKS
|
||||||
|
if(s_uart_debug_nr != -1 && _uart_bus_array[s_uart_debug_nr].lock){
|
||||||
|
xSemaphoreGive(_uart_bus_array[s_uart_debug_nr].lock);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
if(len >= sizeof(loc_buf)){
|
if(len >= sizeof(loc_buf)){
|
||||||
|
Loading…
Reference in New Issue
Block a user