]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Add write timeout of 30s to all TCP server operations, this is further reduced to... 127/head
authorAdam Sutton <dev@adamsutton.me.uk>
Thu, 30 Aug 2012 15:45:43 +0000 (16:45 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Thu, 30 Aug 2012 15:45:43 +0000 (16:45 +0100)
src/tcp.c
src/webui/webui.c

index 27ed5602f655caee96e6d1650e2b2d600c720129..cab3c5fff3c9bac1e5ba30ae4baac28d71e489ce 100644 (file)
--- 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);
index a5daee7f63ace533dcfc794d05cbbff4355af594..4e87b0b1cf02bb43051e0343a69e7a9cabb0e19f 100644 (file)
@@ -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);