Skip to content

Commit 4debeac

Browse files
net: added function to check if a buffer has unhandled data to check before deleting
1 parent 04deec3 commit 4debeac

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

api/net/tcp/read_buffer.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ class Read_buffer {
8484
buffer_t buffer()
8585
{ return buf; }
8686

87+
/**
88+
* @brief Check if internal buffer has unhandled data
89+
*
90+
* @return True if the internal buffer is unique with data and doesnt contain hole
91+
*/
92+
bool has_unhandled_data()
93+
{ return (buf.unique() && (size() > 0) && (missing() == 0)); }
94+
8795
/**
8896
* @brief Exposes the internal buffer (read only)
8997
*

src/net/tcp/read_request.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ namespace tcp {
202202
// if noone is using the buffer right now, (stupid yes)
203203
// AND it contains data without any holes,
204204
// return it to the user
205-
if(buf->buffer().unique() and buf->size() > 0 and buf->missing() == 0)
205+
if (buf->has_unhandled_data())
206206
{
207+
207208
callback(buf->buffer());
208209
}
209210
// reset the first buffer

0 commit comments

Comments
 (0)