aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/BufferedSocket.hxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/event/BufferedSocket.hxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/event/BufferedSocket.hxx b/src/event/BufferedSocket.hxx
index 578000961..31d6c3c57 100644
--- a/src/event/BufferedSocket.hxx
+++ b/src/event/BufferedSocket.hxx
@@ -22,8 +22,12 @@
#include "check.h"
#include "SocketMonitor.hxx"
+#include "util/FifoBuffer.hxx"
#include "Compiler.h"
+#include <assert.h>
+#include <stdint.h>
+
struct fifo_buffer;
class Error;
@@ -31,16 +35,14 @@ class Error;
* A #SocketMonitor specialization that adds an input buffer.
*/
class BufferedSocket : protected SocketMonitor {
- fifo_buffer *input;
+ FifoBuffer<uint8_t, 8192> input;
public:
BufferedSocket(int _fd, EventLoop &_loop)
- :SocketMonitor(_fd, _loop), input(nullptr) {
+ :SocketMonitor(_fd, _loop) {
ScheduleRead();
}
- ~BufferedSocket();
-
using SocketMonitor::IsDefined;
using SocketMonitor::Close;
using SocketMonitor::Write;
@@ -67,7 +69,11 @@ protected:
* does not invalidate the pointer passed to OnSocketInput()
* yet.
*/
- void ConsumeInput(size_t nbytes);
+ void ConsumeInput(size_t nbytes) {
+ assert(IsDefined());
+
+ input.Consume(nbytes);
+ }
enum class InputResult {
/**