diff --git a/porthole/src/linux/client.c b/porthole/src/linux/client.c index 82ee35d3..121803f7 100644 --- a/porthole/src/linux/client.c +++ b/porthole/src/linux/client.c @@ -31,6 +31,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include #include +#include typedef struct { @@ -102,6 +103,9 @@ bool porthole_client_open( return false; } + struct timeval tv = { .tv_sec = 1, .tv_usec = 0 }; + setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)); + struct sockaddr_un addr = { .sun_family = AF_UNIX }; strncpy(addr.sun_path, socket_path, sizeof(addr.sun_path)-1); @@ -182,6 +186,9 @@ static void * porthole_socket_thread(void * opaque) if (recvmsg(handle->socket, &msghdr, 0) < 0) { + if (errno == EAGAIN || errno == EWOULDBLOCK) + continue; + DEBUG_ERROR("Failed to recieve the message"); if (handle->discon_cb) handle->discon_cb();