From 6932da9169a38a5a8eafc63357b9ede00cb46117 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 9 May 2012 16:06:59 +0000 Subject: Support TCP sockets. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4328 a436a847-0d15-0410-975c-d299462d15a1 --- src/socket/SocketReader.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/socket/SocketReader.cpp') diff --git a/src/socket/SocketReader.cpp b/src/socket/SocketReader.cpp index 8b3ed7a1..2d1b5c14 100644 --- a/src/socket/SocketReader.cpp +++ b/src/socket/SocketReader.cpp @@ -142,9 +142,13 @@ SocketReader::_run() pfd.revents = 0; while (!_exit_flag) { + if (feof(f)) { + break; // Lost connection + } + // Wait for input to arrive at socket int ret = poll(&pfd, 1, -1); - if (ret == -1 || (pfd.revents & (POLLHUP | POLLNVAL))) { + if (ret == -1 || (pfd.revents & (POLLERR|POLLHUP|POLLNVAL))) { break; // Hangup } else if (!ret) { continue; // No data, shouldn't happen @@ -156,6 +160,10 @@ SocketReader::_run() continue; // Read nothing, e.g. just whitespace } else if (st) { fprintf(stderr, "Read error: %s\n", serd_strerror(st)); + continue; + } else if (!_msg_node) { + LOG(Raul::error) << "Received empty message" << std::endl; + continue; } // Build an LV2_Atom at chunk.buf from the message -- cgit v1.2.1