[asterisk-commits] simon.perreault: branch group/v6 r86292 - /team/group/v6/trunk/main/netsock.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 18 08:10:59 CDT 2007


Author: simon.perreault
Date: Thu Oct 18 08:10:59 2007
New Revision: 86292

URL: http://svn.digium.com/view/asterisk?view=rev&rev=86292
Log:
Fix fd leak. Again.

Modified:
    team/group/v6/trunk/main/netsock.c

Modified: team/group/v6/trunk/main/netsock.c
URL: http://svn.digium.com/view/asterisk/team/group/v6/trunk/main/netsock.c?view=diff&rev=86292&r1=86291&r2=86292
==============================================================================
--- team/group/v6/trunk/main/netsock.c (original)
+++ team/group/v6/trunk/main/netsock.c Thu Oct 18 08:10:59 2007
@@ -1046,14 +1046,18 @@
 		return 1;
 	}
 	for (res = res0; res; res = res->ai_next) {
+		int ret;
+
 		sockfd = socket(res->ai_family, res->ai_socktype,
 			   res->ai_protocol);
 		if (sockfd < 0)
 			continue;
-		if (connect(sockfd, res->ai_addr, res->ai_addrlen) < 0) {
+
+		ret = connect(sockfd, res->ai_addr, res->ai_addrlen);
+		close(sockfd);
+
+		if (ret < 0)
 			sockfd = -1;
-		}
-		close(sockfd);
 		if (sockfd >= 0)
 			break;  /* we found a good address */
 	}




More information about the asterisk-commits mailing list