fix(esp_modem): DTE command race of timeout vs reply's signal

Race condtion:
* First command timeouted, but the reply came just after evaluation and
set signal variable to GOT_LINE
* Second command should timeout too, but a consistency check validates
that it timeouted and at the same time GOT_LINE (from previous step) and
throws an exception

STR:
* Revert change in esp_modem_dte.cpp
* Run TEST_CASE("DTE command races", "[esp_modem]")

Closes https://github.com/espressif/esp-protocols/issues/110
This commit is contained in:
David Cermak
2022-08-24 19:07:57 +02:00
parent d2f519f9e5
commit a8714730fb
4 changed files with 45 additions and 4 deletions

View File

@ -36,6 +36,7 @@ command_result DTE::command(const std::string &command, got_line_cb got_line, ui
{
Scoped<Lock> l(internal_lock);
command_result res = command_result::TIMEOUT;
signal.clear(GOT_LINE);
command_term->set_read_cb([&](uint8_t *data, size_t len) {
if (!data) {
data = buffer.get();