]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
satip client: add hard timeout for the incoming data
authorJaroslav Kysela <perex@perex.cz>
Sun, 25 Nov 2018 22:04:51 +0000 (23:04 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 25 Nov 2018 22:04:51 +0000 (23:04 +0100)
src/input/mpegts/satip/satip_frontend.c

index 231b36351888c77706ad61a850906868b4198c32..4741fa7924507236c41e98e790f4c96b56e86048 100644 (file)
@@ -1581,7 +1581,7 @@ satip_frontend_input_thread ( void *aux )
   int rtsp_flags, position, reply;
   uint32_t seq, unc;
   udp_multirecv_t um;
-  uint64_t u64, u64_2;
+  uint64_t u64, u64_2, last_data;
   long stream_id;
 
   /* If set - the thread will be cancelled */
@@ -1885,6 +1885,8 @@ new_tune:
   udp_rtp_packet_destroy_all(lfe);
   lfe->sf_skip_ts = MINMAX(lfe->sf_device->sd_skip_ts, 0, 200) * 188;
   
+  last_data = mclk();
+
   while ((reply || running) && !fatal) {
 
     nfds = tvhpoll_wait(efd, ev, 1, ms);
@@ -1927,6 +1929,13 @@ new_tune:
       continue;
     }
 
+    if (last_data + sec2mono(5) < mclk()) {
+      tvhwarn(LS_SATIP, "%s - no data received, restarting RTSP", buf);
+      satip_frontend_tuning_error(lfe, tr);
+      fatal = 1;
+      continue;
+    }
+
     if (nfds < 1) continue;
 
     if (ev[0].ptr == rtsp) {
@@ -2046,6 +2055,7 @@ new_tune:
     if (ev[0].ptr == rtcp) {
       c = recv(rtcp->fd, b, sizeof(b), MSG_DONTWAIT);
       if (c > 0) {
+        last_data = mclk();
         pthread_mutex_lock(&lfe->sf_dvr_lock);
         if (lfe->sf_req == lfe->sf_req_thread)
           satip_frontend_decode_rtcp(lfe, buf, mmi, b, c);
@@ -2069,6 +2079,8 @@ new_tune:
       tvherror(LS_SATIP, "%s - multirecv error %d (%s)",
                buf, errno, strerror(errno));
       break;
+    } else {
+      last_data = mclk();
     }
 
     for (i = 0, unc = 0; i < tc; i++) {