diff --git a/client.cpp b/client.cpp index e815d86..e2889aa 100644 --- a/client.cpp +++ b/client.cpp @@ -309,6 +309,9 @@ std::string Client::getKeepAliveInfoString() const void Client::resetBuffersIfEligible() { readbuf.resetSizeIfEligable(initialBufferSize); + + // Write buffers are written to from other threads, and this resetting takes place from the Client's own thread, so we need to lock. + std::lock_guard locker(writeBufMutex); writebuf.resetSizeIfEligable(initialBufferSize); }