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 */