Protect write buffer queue with a per-client mutex

This prevents a race condicion of the ::add() method modifying the queue
and being preempted by the high-priority asyncTcpSock task that in turn
flushes the same queue to the socket, therefore modifying the queue.
This commit is contained in:
Alex Villacís Lasso
2020-12-21 18:21:27 -05:00
parent 9ee3bda5ae
commit 2bb8788ec1
2 changed files with 27 additions and 30 deletions

View File

@@ -180,6 +180,7 @@ class AsyncClient : public AsyncSocketBase
} queued_writebuf;
// Queue of buffers to write to socket
SemaphoreHandle_t _write_mutex;
std::deque<queued_writebuf> _writeQueue;
bool _ack_timeout_signaled = false;