]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
udp: improve udp_bind_double
authorJaroslav Kysela <perex@perex.cz>
Sun, 26 Oct 2014 21:41:53 +0000 (22:41 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sun, 26 Oct 2014 21:42:07 +0000 (22:42 +0100)
src/udp.c

index 6f84ba255d6c8cf96d932ce1810f3ad2b20002bf..5e97be4b65777f046569d2d265fce5a788a2095d 100644 (file)
--- a/src/udp.c
+++ b/src/udp.c
@@ -291,9 +291,8 @@ udp_bind_double ( udp_connection_t **_u1, udp_connection_t **_u2,
                   const char *ifname, int rxsize1, int rxsize2 )
 {
   udp_connection_t *u1 = NULL, *u2 = NULL;
-  udp_connection_t *ucs[10] = { NULL, NULL, NULL, NULL, NULL,
-                                NULL, NULL, NULL, NULL, NULL };
-  int pos = 0, i, port2;
+  udp_connection_t *ucs[10];
+  int tst = 40, pos = 0, i, port2;
 
   memset(&ucs, 0, sizeof(ucs));
   while (1) {
@@ -307,6 +306,11 @@ udp_bind_double ( udp_connection_t **_u1, udp_connection_t **_u2,
       if (u2 != NULL && u2 != UDP_FATAL_ERROR)
         break;
     }
+    if (tst) {
+      udp_close(u1);
+      tst--;
+      continue;
+    }
     ucs[pos++] = u1;
     if (port || pos >= ARRAY_SIZE(ucs))
       goto fail;