Revision
14431
Author
anthm
Date
2009-07-30 11:20:47 -0500 (Thu, 30 Jul 2009)

Log Message

shot in the dark for FSCORE-410

Modified Paths

Diff

Modified: freeswitch/trunk/src/switch_nat.c (14430 => 14431)


--- freeswitch/trunk/src/switch_nat.c	2009-07-30 00:35:53 UTC (rev 14430)
+++ freeswitch/trunk/src/switch_nat.c	2009-07-30 16:20:47 UTC (rev 14431)
@@ -134,12 +134,15 @@
 	char *pubaddr = NULL;
 	fd_set fds;
 	natpmp_t natpmp;
+	const char *err = NULL;
+	
+	if ((r = initnatpmp(&natpmp)) < 0) {
+		err = "init failed";
+		goto end;
+	}
 
-
-	initnatpmp(&natpmp);
-	r = sendpublicaddressrequest(&natpmp);
-
-	if (r < 0) {
+	if ((r = sendpublicaddressrequest(&natpmp)) < 0) {
+		err = "pub addr req failed";
 		goto end;
 	}
 
@@ -150,16 +153,24 @@
 
 		FD_ZERO(&fds);
 		FD_SET(natpmp.s, &fds);
-		getnatpmprequesttimeout(&natpmp, &timeout);
-		select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
+
+		if ((r = getnatpmprequesttimeout(&natpmp, &timeout)) < 0) {
+			err = "get timeout failed";
+			goto end;
+		}
+
+		if ((r = select(FD_SETSIZE, &fds, NULL, NULL, &timeout)) < 0) {
+			err = "select failed";
+			goto end;
+		}
 		r = readnatpmpresponseorretry(&natpmp, &response);
 	} while(r == NATPMP_TRYAGAIN && i < max);
 
 	if (r < 0) {
+		err = "general error";
 		goto end;
 	}
 
-
 	pubaddr = inet_ntoa(response.pnu.publicaddress.addr);
 	switch_copy_string(pub_addr, pubaddr, IP_LEN);
 	nat_globals.nat_type = SWITCH_NAT_TYPE_PMP;
@@ -168,6 +179,10 @@
 
  end:
 
+	if (err) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error checking for PMP [%s]\n", err);
+	}
+
 	return r;
 }