From 34cadcee27725f0b87884d2a0a9e3d35faac27b2 Mon Sep 17 00:00:00 2001 From: Alex Hultman Date: Mon, 20 Sep 2021 15:13:11 +0000 Subject: [PATCH] getBufferedAmount should only see totalLength --- src/AsyncSocket.h | 3 ++- src/AsyncSocketData.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/AsyncSocket.h b/src/AsyncSocket.h index 20f023b..188df64 100644 --- a/src/AsyncSocket.h +++ b/src/AsyncSocket.h @@ -134,7 +134,8 @@ protected: /* Returns the user space backpressure. */ unsigned int getBufferedAmount() { - return (unsigned int) getAsyncSocketData()->buffer.size(); + /* We return the actual amount of bytes in backbuffer, including pendingRemoval */ + return (unsigned int) getAsyncSocketData()->buffer.totalLength(); } /* Returns the text representation of an IPv4 or IPv6 address */ diff --git a/src/AsyncSocketData.h b/src/AsyncSocketData.h index 5f3d649..94575d8 100644 --- a/src/AsyncSocketData.h +++ b/src/AsyncSocketData.h @@ -62,6 +62,10 @@ struct BackPressure { size_t size() { return length(); } + /* The total length, incuding pending removal */ + size_t totalLength() { + return buffer.length(); + } }; /* Depending on how we want AsyncSocket to function, this will need to change */