summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stun.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/stun.c b/stun.c
index e39e76a..9917c6d 100644
--- a/stun.c
+++ b/stun.c
@@ -100,7 +100,7 @@ static int stun_test(const char *server_ip, int server_port,
sizeof(daddr));
if (ret != len) {
printf("Error sending request (%s)!\n", strerror(errno));
- return -EIO;
+ goto close_error;
}
timeout.tv_sec = TIMEOUT / 1000;
@@ -112,7 +112,7 @@ static int stun_test(const char *server_ip, int server_port,
ret = select(sock + 1, &fdset, NULL, NULL, &timeout);
if (ret <= 0) {
printf("STUN server timeout!\n");
- return -EIO;
+ goto close_error;
}
memset(rpkt, 0, sizeof(rpkt));
@@ -166,6 +166,9 @@ next:
}
return 0;
+close_error:
+ close(sock);
+ return -EIO;
}
int print_stun_probe(char *server, int sport, int tport)