]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fix #1467 - capmt: try to reconnect when oscam was restarted 229/head
authorMariusz Bialonczyk <manio@skyboo.net>
Sun, 20 Jan 2013 17:00:26 +0000 (18:00 +0100)
committerMariusz Bialonczyk <manio@skyboo.net>
Tue, 22 Jan 2013 12:59:30 +0000 (13:59 +0100)
src/capmt.c

index 7f88377d8f84d4f66ba75eb60f183b83df847daf..562296040c8c45cedd88af9f607e85a95d3e4cfd 100644 (file)
@@ -264,6 +264,14 @@ capmt_send_msg(capmt_t *capmt, int sid, const uint8_t *buf, size_t len)
       tvhlog(LOG_DEBUG, "capmt", "%s: added: i=%d", __FUNCTION__, i);
     }
 
+    // check if the socket is still alive by writing 0 bytes
+    if (capmt->capmt_sock[i] > 0) {
+      if (write(capmt->capmt_sock[i], NULL, 0) < 0)
+        capmt->capmt_sock[i] = 0;
+      else if (found)
+        return 0;
+    }
+
     // opening socket and sending
     if (capmt->capmt_sock[i] == 0) {
       capmt->capmt_sock[i] = tvh_socket(AF_LOCAL, SOCK_STREAM, 0);
@@ -663,7 +671,6 @@ capmt_table_input(struct th_descrambler *td, struct service *t,
   capmt_t *capmt = ct->ct_capmt;
   int adapter_num = t->s_dvb_mux_instance->tdmi_adapter->tda_adapter_num;
   int total_caids = 0, current_caid = 0;
-  int i;
 
   caid_t *c;
 
@@ -844,17 +851,7 @@ capmt_table_input(struct th_descrambler *td, struct service *t,
           buf[9] = pmtversion;
           pmtversion = (pmtversion + 1) & 0x1F;
 
-          int found = 0;
-          if (capmt->capmt_oscam) {
-            for (i = 0; i < MAX_SOCKETS; i++) {
-              if (capmt->sids[i] == sid) {
-                found = 1;
-                break;
-              }
-            }
-          }
-          if ((capmt->capmt_oscam && !found) || !capmt->capmt_oscam)
-            capmt_send_msg(capmt, sid, buf, pos);
+          capmt_send_msg(capmt, sid, buf, pos);
           break;
         }
       default: