From: Adam Sutton Date: Thu, 30 Aug 2012 15:45:43 +0000 (+0100) Subject: Add write timeout of 30s to all TCP server operations, this is further reduced to... X-Git-Tag: 3.3~107 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F127%2Fhead;p=thirdparty%2Ftvheadend.git Add write timeout of 30s to all TCP server operations, this is further reduced to 5s for streaming output. Fixes #1054. --- diff --git a/src/tcp.c b/src/tcp.c index 27ed5602f..cab3c5fff 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -370,6 +370,7 @@ static void * tcp_server_start(void *aux) { tcp_server_launch_t *tsl = aux; + struct timeval to; int val; val = 1; @@ -393,6 +394,9 @@ tcp_server_start(void *aux) val = 1; setsockopt(tsl->fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); + to.tv_sec = 30; + to.tv_usec = 0; + setsockopt(tsl->fd, SOL_SOCKET, SO_SNDTIMEO, &to, sizeof(to)); tsl->start(tsl->fd, tsl->opaque, &tsl->peer, &tsl->self); free(tsl); diff --git a/src/webui/webui.c b/src/webui/webui.c index a5daee7f6..4e87b0b1c 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -161,6 +161,11 @@ http_stream_run(http_connection_t *hc, streaming_queue_t *sq, else name = "Live Stream"; + /* reduce timeout on write() for streaming */ + tp.tv_sec = 5; + tp.tv_usec = 0; + setsockopt(hc->hc_fd, SOL_SOCKET, SO_SNDTIMEO, &tp, sizeof(tp)); + while(run) { pthread_mutex_lock(&sq->sq_mutex); sm = TAILQ_FIRST(&sq->sq_queue);