summaryrefslogtreecommitdiffstats
path: root/src/socket
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-16 00:59:35 +0000
committerDavid Robillard <d@drobilla.net>2012-08-16 00:59:35 +0000
commitda4c1fcad194f4f3f399f6a4a731df34567c95ef (patch)
tree22c875232a4639f0f80d818e3a399e16c4ffe6ad /src/socket
parentd64815e24c043ac87b1504c5f02e93b11c4d8285 (diff)
downloadingen-da4c1fcad194f4f3f399f6a4a731df34567c95ef.tar.gz
ingen-da4c1fcad194f4f3f399f6a4a731df34567c95ef.tar.bz2
ingen-da4c1fcad194f4f3f399f6a4a731df34567c95ef.zip
Remove Raul::Slave class.
Merge Thread::stop() and Thread::join(). Clean thread shut down without the use of pthread_cancel(). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4708 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/socket')
-rw-r--r--src/socket/Socket.cpp9
-rw-r--r--src/socket/Socket.hpp6
-rw-r--r--src/socket/SocketListener.cpp10
-rw-r--r--src/socket/SocketReader.cpp1
4 files changed, 22 insertions, 4 deletions
diff --git a/src/socket/Socket.cpp b/src/socket/Socket.cpp
index 13a684bc..998d1cdb 100644
--- a/src/socket/Socket.cpp
+++ b/src/socket/Socket.cpp
@@ -188,5 +188,14 @@ Socket::close()
}
}
+void
+Socket::shutdown()
+{
+ if (_sock != -1) {
+ ::shutdown(_sock, SHUT_RDWR);
+ _sock = -1;
+ }
+}
+
} // namespace Ingen
} // namespace Socket
diff --git a/src/socket/Socket.hpp b/src/socket/Socket.hpp
index 49d03d48..1406d87e 100644
--- a/src/socket/Socket.hpp
+++ b/src/socket/Socket.hpp
@@ -81,6 +81,12 @@ public:
/** Close the socket. */
void close();
+ /** Shut down the socket.
+ * This terminates any connections associated with the sockets, and will
+ * (unlike close()) cause a poll on the socket to return.
+ */
+ void shutdown();
+
private:
bool set_addr(const Raul::URI& uri);
diff --git a/src/socket/SocketListener.cpp b/src/socket/SocketListener.cpp
index 936dd0e0..58797fa8 100644
--- a/src/socket/SocketListener.cpp
+++ b/src/socket/SocketListener.cpp
@@ -65,7 +65,9 @@ SocketListener::SocketListener(Ingen::World& world)
SocketListener::~SocketListener()
{
- stop();
+ _exit_flag = true;
+ _unix_sock.shutdown();
+ _net_sock.shutdown();
join();
_unix_sock.close();
_net_sock.close();
@@ -92,10 +94,12 @@ SocketListener::_run()
++nfds;
}
- while (!_exit_flag) {
+ while (true) {
// Wait for input to arrive at a socket
int ret = poll(pfds, nfds, -1);
- if (ret == -1) {
+ if (_exit_flag) {
+ break;
+ } else if (ret == -1) {
LOG(Raul::error) << "Poll error: " << strerror(errno) << std::endl;
break;
} else if (ret == 0) {
diff --git a/src/socket/SocketReader.cpp b/src/socket/SocketReader.cpp
index b73b9eb0..2301ba69 100644
--- a/src/socket/SocketReader.cpp
+++ b/src/socket/SocketReader.cpp
@@ -46,7 +46,6 @@ SocketReader::SocketReader(Ingen::World& world,
SocketReader::~SocketReader()
{
- stop();
join();
}