diff options
author | Attila Molnar <attilamolnar@hush.com> | 2016-08-08 14:39:09 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2016-08-08 14:39:09 +0200 |
commit | fd573d17ca199e87363e95e6a0fd5b1350669fe1 (patch) | |
tree | 76e85e2faf65ffc8a5fdddc651edac9bae15829b | |
parent | 6466e3093a4e5e996f2c9f3c4fd9f6eb1ac0e7b9 (diff) |
Call StreamSocket::OnDataReady() from only one place
Call it whenever the recvq gets bigger than it was before the read
-rw-r--r-- | src/inspsocket.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index f6ca53164..89144dee0 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -141,18 +141,24 @@ bool StreamSocket::GetNextLine(std::string& line, char delim) void StreamSocket::DoRead() { + const std::string::size_type prevrecvqsize = recvq.size(); + if (GetIOHook()) { int rv = GetIOHook()->OnStreamSocketRead(this, recvq); - if (rv > 0) - OnDataReady(); if (rv < 0) + { SetError("Read Error"); // will not overwrite a better error message + return; + } } else { ReadToRecvQ(recvq); } + + if (recvq.size() > prevrecvqsize) + OnDataReady(); } int StreamSocket::ReadToRecvQ(std::string& rq) @@ -163,13 +169,11 @@ int StreamSocket::ReadToRecvQ(std::string& rq) { SocketEngine::ChangeEventMask(this, FD_WANT_FAST_READ | FD_ADD_TRIAL_READ); rq.append(ReadBuffer, n); - OnDataReady(); } else if (n > 0) { SocketEngine::ChangeEventMask(this, FD_WANT_FAST_READ); rq.append(ReadBuffer, n); - OnDataReady(); } else if (n == 0) { |