aboutsummaryrefslogtreecommitdiffstats
path: root/src/event
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-06 18:02:57 +0100
committerMax Kellermann <max@duempel.org>2014-01-06 18:26:55 +0100
commit793962c5b86cd063036a2d28907b0b33012483e1 (patch)
tree39531d85b0ab2bf480f74c74da788e566991ee25 /src/event
parent0d20130d07d69bb8ac4392af8f2ed25e5ea0bbad (diff)
downloadmpd-793962c5b86cd063036a2d28907b0b33012483e1.tar.gz
mpd-793962c5b86cd063036a2d28907b0b33012483e1.tar.xz
mpd-793962c5b86cd063036a2d28907b0b33012483e1.zip
event/SocketMonitor: don't close the socket automatically
Users now have to call Close() explicitly. This simplifies using the class, as most users have automatic socket management already, and Steal() had to be used often.
Diffstat (limited to 'src/event')
-rw-r--r--src/event/Loop.cxx3
-rw-r--r--src/event/MultiSocketMonitor.hxx1
-rw-r--r--src/event/ServerSocket.cxx3
-rw-r--r--src/event/SignalMonitor.cxx8
-rw-r--r--src/event/SocketMonitor.cxx2
-rw-r--r--src/event/SocketMonitor.hxx5
6 files changed, 8 insertions, 14 deletions
diff --git a/src/event/Loop.cxx b/src/event/Loop.cxx
index 58c25e040..6281b09ec 100644
--- a/src/event/Loop.cxx
+++ b/src/event/Loop.cxx
@@ -42,9 +42,6 @@ EventLoop::~EventLoop()
{
assert(idle.empty());
assert(timers.empty());
-
- /* avoid closing the WakeFD twice */
- SocketMonitor::Steal();
}
void
diff --git a/src/event/MultiSocketMonitor.hxx b/src/event/MultiSocketMonitor.hxx
index d6ad3b177..963745be1 100644
--- a/src/event/MultiSocketMonitor.hxx
+++ b/src/event/MultiSocketMonitor.hxx
@@ -143,7 +143,6 @@ public:
i->SetEvents(events);
prev = i;
} else {
- i->Steal();
fds.erase_after(prev);
}
}
diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx
index a05d7bde2..64e38776f 100644
--- a/src/event/ServerSocket.cxx
+++ b/src/event/ServerSocket.cxx
@@ -90,6 +90,9 @@ public:
~OneServerSocket() {
g_free(address);
+
+ if (IsDefined())
+ Close();
}
unsigned GetSerial() const {
diff --git a/src/event/SignalMonitor.cxx b/src/event/SignalMonitor.cxx
index bb75f49a3..eac011616 100644
--- a/src/event/SignalMonitor.cxx
+++ b/src/event/SignalMonitor.cxx
@@ -58,14 +58,6 @@ public:
#endif
}
- ~SignalMonitor() {
- /* prevent the descriptor to be closed twice */
-#ifdef USE_SIGNALFD
- if (SocketMonitor::IsDefined())
-#endif
- SocketMonitor::Steal();
- }
-
using SocketMonitor::GetEventLoop;
#ifdef USE_SIGNALFD
diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx
index 92693949f..ef2128684 100644
--- a/src/event/SocketMonitor.cxx
+++ b/src/event/SocketMonitor.cxx
@@ -43,7 +43,7 @@ SocketMonitor::Dispatch(unsigned flags)
SocketMonitor::~SocketMonitor()
{
if (IsDefined())
- Close();
+ Cancel();
}
void
diff --git a/src/event/SocketMonitor.hxx b/src/event/SocketMonitor.hxx
index 3a84dc094..d0fcf1b57 100644
--- a/src/event/SocketMonitor.hxx
+++ b/src/event/SocketMonitor.hxx
@@ -44,6 +44,9 @@ class EventLoop;
* #EventLoop will invoke virtual method OnSocketReady() as soon as
* any of the subscribed events are ready.
*
+ * This class does not feel responsible for closing the socket. Call
+ * Close() to do it manually.
+ *
* This class is not thread-safe, all methods must be called from the
* thread that runs the #EventLoop, except where explicitly documented
* as thread-safe.
@@ -91,7 +94,7 @@ public:
/**
* "Steal" the socket descriptor. This abandons the socket
- * and puts the responsibility for closing it to the caller.
+ * and returns it.
*/
int Steal();