From 32b51737bac9562f5c2d20cdaa5cf214640e2c2c Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sun, 26 Oct 2014 22:41:53 +0100 Subject: [PATCH] udp: improve udp_bind_double --- src/udp.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/udp.c b/src/udp.c index 6f84ba25..5e97be4b 100644 --- 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;