aboutsummaryrefslogtreecommitdiffstats
path: root/src/event
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-30 10:53:32 +0100
committerMax Kellermann <max@duempel.org>2013-01-30 11:03:44 +0100
commit4ad7456428913f5232768367f2c0694bcb4540bb (patch)
tree213a06a779ca285f6cec035cb3385bd0b96d0164 /src/event
parent73f36858bb4026eff7c9e44007c87e870d324a5f (diff)
downloadmpd-4ad7456428913f5232768367f2c0694bcb4540bb.tar.gz
mpd-4ad7456428913f5232768367f2c0694bcb4540bb.tar.xz
mpd-4ad7456428913f5232768367f2c0694bcb4540bb.zip
event/SocketMonitor: OnSocketReady() returns bool
Diffstat (limited to 'src/event')
-rw-r--r--src/event/BufferedSocket.cxx10
-rw-r--r--src/event/BufferedSocket.hxx2
-rw-r--r--src/event/SocketMonitor.hxx5
3 files changed, 11 insertions, 6 deletions
diff --git a/src/event/BufferedSocket.cxx b/src/event/BufferedSocket.cxx
index b95519e49..dec60b5f7 100644
--- a/src/event/BufferedSocket.cxx
+++ b/src/event/BufferedSocket.cxx
@@ -202,21 +202,21 @@ BufferedSocket::ConsumeInput(size_t nbytes)
fifo_buffer_consume(input, nbytes);
}
-void
+bool
BufferedSocket::OnSocketReady(unsigned flags)
{
assert(IsDefined());
if (gcc_unlikely(flags & (ERROR|HANGUP))) {
OnSocketClosed();
- return;
+ return false;
}
if (flags & READ) {
assert(input == nullptr || !fifo_buffer_is_full(input));
if (!ReadToBuffer() || !ResumeInput())
- return;
+ return false;
if (input == nullptr || !fifo_buffer_is_full(input))
ScheduleRead();
@@ -233,6 +233,8 @@ BufferedSocket::OnSocketReady(unsigned flags)
assert(!output.IsEmpty());
if (!WriteFromBuffer())
- return;
+ return false;
}
+
+ return true;
}
diff --git a/src/event/BufferedSocket.hxx b/src/event/BufferedSocket.hxx
index 6e55a5e19..23fd97d38 100644
--- a/src/event/BufferedSocket.hxx
+++ b/src/event/BufferedSocket.hxx
@@ -113,7 +113,7 @@ protected:
virtual void OnSocketClosed() = 0;
private:
- virtual void OnSocketReady(unsigned flags) override;
+ virtual bool OnSocketReady(unsigned flags) override;
};
#endif
diff --git a/src/event/SocketMonitor.hxx b/src/event/SocketMonitor.hxx
index b8ded1967..c815e4f53 100644
--- a/src/event/SocketMonitor.hxx
+++ b/src/event/SocketMonitor.hxx
@@ -115,7 +115,10 @@ public:
ssize_t Write(const void *data, size_t length);
protected:
- virtual void OnSocketReady(unsigned flags) = 0;
+ /**
+ * @return false if the socket has been closed
+ */
+ virtual bool OnSocketReady(unsigned flags) = 0;
public:
/* GSource callbacks */