diff options
author | David Robillard <d@drobilla.net> | 2015-10-02 00:06:20 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-10-02 00:06:20 +0000 |
commit | c2d083a0a904072f0ec5c067cdea45147301e5a2 (patch) | |
tree | ee7b4131ddc9657d6b11f80b7f8eff42b977fac3 | |
parent | 736546bfd97580e31297e8e000f188366a8afc09 (diff) | |
download | ingen-c2d083a0a904072f0ec5c067cdea45147301e5a2.tar.gz ingen-c2d083a0a904072f0ec5c067cdea45147301e5a2.tar.bz2 ingen-c2d083a0a904072f0ec5c067cdea45147301e5a2.zip |
Unregister socket clients on hangup.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5735 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | ingen/SocketReader.hpp | 5 | ||||
-rw-r--r-- | src/SocketReader.cpp | 1 | ||||
-rw-r--r-- | src/server/SocketServer.hpp | 8 |
3 files changed, 13 insertions, 1 deletions
diff --git a/ingen/SocketReader.hpp b/ingen/SocketReader.hpp index 88d24994..4baf4696 100644 --- a/ingen/SocketReader.hpp +++ b/ingen/SocketReader.hpp @@ -36,7 +36,10 @@ public: Interface& iface, SPtr<Raul::Socket> sock); - ~SocketReader(); + virtual ~SocketReader(); + +protected: + virtual void on_hangup() {} private: void run(); diff --git a/src/SocketReader.cpp b/src/SocketReader.cpp index d57cda29..c9b31cb5 100644 --- a/src/SocketReader.cpp +++ b/src/SocketReader.cpp @@ -154,6 +154,7 @@ SocketReader::run() // Wait for input to arrive at socket int ret = poll(&pfd, 1, -1); if (ret == -1 || (pfd.revents & (POLLERR|POLLHUP|POLLNVAL))) { + on_hangup(); break; // Hangup } else if (!ret) { continue; // No data, shouldn't happen diff --git a/src/server/SocketServer.hpp b/src/server/SocketServer.hpp index a1811334..fc9fdeae 100644 --- a/src/server/SocketServer.hpp +++ b/src/server/SocketServer.hpp @@ -47,7 +47,15 @@ public: } ~SocketServer() { + if (_writer) { + _engine.unregister_client(_writer); + } + } + +protected: + void on_hangup() { _engine.unregister_client(_writer); + _writer.reset(); } private: |