From fd573d17ca199e87363e95e6a0fd5b1350669fe1 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 8 Aug 2016 14:39:09 +0200 Subject: Call StreamSocket::OnDataReady() from only one place Call it whenever the recvq gets bigger than it was before the read --- src/inspsocket.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/inspsocket.cpp') 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) { -- cgit v1.2.3