aboutsummaryrefslogtreecommitdiffstats
path: root/src/event/SocketMonitor.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-27 22:37:01 +0100
committerMax Kellermann <max@duempel.org>2013-01-27 22:38:14 +0100
commit068f191c0d9459554db536ac3d7f64f9b9338381 (patch)
treea138dd0d1505cef6af6e73e5ced50a559d5f5364 /src/event/SocketMonitor.cxx
parent6bf6c9215b413ad1e27328d2b2597c9489376221 (diff)
downloadmpd-068f191c0d9459554db536ac3d7f64f9b9338381.tar.gz
mpd-068f191c0d9459554db536ac3d7f64f9b9338381.tar.xz
mpd-068f191c0d9459554db536ac3d7f64f9b9338381.zip
event/SocketMonitor: add method Steal()
Diffstat (limited to 'src/event/SocketMonitor.cxx')
-rw-r--r--src/event/SocketMonitor.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx
index b75dc72a4..57364c883 100644
--- a/src/event/SocketMonitor.cxx
+++ b/src/event/SocketMonitor.cxx
@@ -105,17 +105,25 @@ SocketMonitor::Open(int _fd)
g_source_add_poll(&source->base, &poll);
}
-void
-SocketMonitor::Close()
+int
+SocketMonitor::Steal()
{
assert(IsDefined());
Cancel();
- close_socket(fd);
+ int result = fd;
fd = -1;
g_source_destroy(&source->base);
g_source_unref(&source->base);
source = nullptr;
+
+ return result;
+}
+
+void
+SocketMonitor::Close()
+{
+ close_socket(Steal());
}