mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:47:34 +00:00
LibCore: Make sure BufferedSocket takes the buffer into account
pending_bytes() and can_read_without_blocking() should also take the buffered data into account, otherwise we'll end up pretending that the socket cannot be read from while it has buffered data.
This commit is contained in:
parent
33a4048f55
commit
f4d841077d
1 changed files with 10 additions and 2 deletions
|
@ -684,6 +684,11 @@ public:
|
|||
return m_buffer.size();
|
||||
}
|
||||
|
||||
size_t buffered_data_size() const
|
||||
{
|
||||
return m_buffered_size;
|
||||
}
|
||||
|
||||
void clear_buffer()
|
||||
{
|
||||
m_buffered_size = 0;
|
||||
|
@ -803,8 +808,11 @@ public:
|
|||
virtual bool is_eof() const override { return m_helper.is_eof(); }
|
||||
virtual bool is_open() const override { return m_helper.stream().is_open(); }
|
||||
virtual void close() override { m_helper.stream().close(); }
|
||||
virtual ErrorOr<size_t> pending_bytes() const override { return m_helper.stream().pending_bytes(); }
|
||||
virtual ErrorOr<bool> can_read_without_blocking(int timeout = 0) const override { return m_helper.stream().can_read_without_blocking(timeout); }
|
||||
virtual ErrorOr<size_t> pending_bytes() const override
|
||||
{
|
||||
return TRY(m_helper.stream().pending_bytes()) + m_helper.buffered_data_size();
|
||||
}
|
||||
virtual ErrorOr<bool> can_read_without_blocking(int timeout = 0) const override { return m_helper.buffered_data_size() > 0 || TRY(m_helper.stream().can_read_without_blocking(timeout)); }
|
||||
virtual ErrorOr<void> set_blocking(bool enabled) override { return m_helper.stream().set_blocking(enabled); }
|
||||
virtual ErrorOr<void> set_close_on_exec(bool enabled) override { return m_helper.stream().set_close_on_exec(enabled); }
|
||||
virtual void set_notifications_enabled(bool enabled) override { m_helper.stream().set_notifications_enabled(enabled); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue