From 0287ac794e5117772953394fcbc93912cf8e3c22 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 7 Aug 2013 23:56:49 +0200 Subject: event/SocketMonitor: add assertions --- src/event/SocketMonitor.cxx | 6 ++++++ src/event/SocketMonitor.hxx | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'src/event') diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx index 92aac9a92..9bb6e47cf 100644 --- a/src/event/SocketMonitor.cxx +++ b/src/event/SocketMonitor.cxx @@ -138,6 +138,8 @@ SocketMonitor::Close() SocketMonitor::ssize_t SocketMonitor::Read(void *data, size_t length) { + assert(IsDefined()); + int flags = 0; #ifdef MSG_DONTWAIT flags |= MSG_DONTWAIT; @@ -149,6 +151,8 @@ SocketMonitor::Read(void *data, size_t length) SocketMonitor::ssize_t SocketMonitor::Write(const void *data, size_t length) { + assert(IsDefined()); + int flags = 0; #ifdef MSG_NOSIGNAL flags |= MSG_NOSIGNAL; @@ -163,5 +167,7 @@ SocketMonitor::Write(const void *data, size_t length) void SocketMonitor::CommitEventFlags() { + assert(IsDefined()); + loop.WakeUp(); } diff --git a/src/event/SocketMonitor.hxx b/src/event/SocketMonitor.hxx index c60b8efdf..4cd214018 100644 --- a/src/event/SocketMonitor.hxx +++ b/src/event/SocketMonitor.hxx @@ -87,6 +87,8 @@ public: void Close(); void Schedule(unsigned flags) { + assert(IsDefined()); + poll.events = flags; poll.revents &= flags; CommitEventFlags(); @@ -137,10 +139,14 @@ private: void CommitEventFlags(); bool Check() const { + assert(IsDefined()); + return (poll.revents & poll.events) != 0; } void Dispatch() { + assert(IsDefined()); + OnSocketReady(poll.revents & poll.events); } }; -- cgit v1.2.3