From ffdf1c917a0f22db8c88dee8cd17886302864a79 Mon Sep 17 00:00:00 2001 From: Wiebe Cazemier Date: Sun, 13 Dec 2020 10:44:07 +0100 Subject: [PATCH] Read buf fixes --- client.cpp | 6 +++++- client.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/client.cpp b/client.cpp index 2a57cb2..8b1aa3b 100644 --- a/client.cpp +++ b/client.cpp @@ -40,7 +40,7 @@ bool Client::readFdIntoBuffer() { wi += n; - if (getReadBufBytesUsed() >= readBufsize) + if (getReadBufMaxWriteSize() == 0) { growReadBuffer(); } @@ -53,12 +53,16 @@ bool Client::readFdIntoBuffer() if (errno == EAGAIN || errno == EWOULDBLOCK) break; else + { + std::cerr << strerror(errno) << std::endl; return false; + } } } if (n == 0) // client disconnected. { + std::cerr << "normal disconnect" << std::endl; return false; } diff --git a/client.h b/client.h index 95fcf8f..e1a37cd 100644 --- a/client.h +++ b/client.h @@ -42,6 +42,7 @@ class Client ThreadData_p threadData; std::mutex writeBufMutex; + // Note: this is not the inverse of free space, because there can be non-used lead-in in the buffer! size_t getReadBufBytesUsed() { return wi - ri; @@ -68,6 +69,7 @@ class Client return available; } + // Note: this is not the inverse of free space, because there can be non-used lead-in in the buffer! size_t getWriteBufBytesUsed() { return wwi - wri; -- libgit2 0.21.4