[asterisk-commits] mattf: branch mattf/bug13495 r163758 - /team/mattf/bug13495/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Dec 12 15:37:36 CST 2008


Author: mattf
Date: Fri Dec 12 15:37:35 2008
New Revision: 163758

URL: http://svn.digium.com/view/asterisk?view=rev&rev=163758
Log:
Set non blocking mode on TCP socket

Modified:
    team/mattf/bug13495/channels/chan_dahdi.c

Modified: team/mattf/bug13495/channels/chan_dahdi.c
URL: http://svn.digium.com/view/asterisk/team/mattf/bug13495/channels/chan_dahdi.c?view=diff&rev=163758&r1=163757&r2=163758
==============================================================================
--- team/mattf/bug13495/channels/chan_dahdi.c (original)
+++ team/mattf/bug13495/channels/chan_dahdi.c Fri Dec 12 15:37:35 2008
@@ -10384,13 +10384,13 @@
 		} else 
 			nextms = -1;
 
-		ast_mutex_unlock(&linkset->lock);
-
 		for (i = 0; i < linkset->numsigchans; i++) {
 			pollers[i].fd = linkset->fds[i];
 			pollers[i].events = ss7_pollflags(ss7, linkset->fds[i]);
 			pollers[i].revents = 0;
 		}
+
+		ast_mutex_unlock(&linkset->lock);
 
 		res = poll(pollers, linkset->numsigchans, nextms);
 		if ((res < 0) && (errno != EINTR)) {
@@ -14309,12 +14309,23 @@
 			}
 		} else if (!strcasecmp("tcp", tech)) {
 			struct sockaddr_in my_addr;
+			int flags;
 
 			if ((link->fds[curfd] = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
 				ast_log(LOG_ERROR, "Unable to open socket for SS7 slave server\n");
 				return -1;
 			}
 			
+			if ((flags = fcntl(link->fds[curfd], F_GETFL)) < 0) {
+				ast_log(LOG_WARNING,"Fcntl(F_GETFL) failed: %s\n", strerror(errno));
+				close(link->fds[curfd]);
+				return 0;
+			}
+			if (fcntl(link->fds[curfd], F_SETFL, flags | O_NONBLOCK) < 0) {
+				ast_log(LOG_WARNING,"Fnctl(F_SETFL) failed: %s\n", strerror(errno));
+				close(link->fds[curfd]);
+				return 0;
+			}
 			memset(&my_addr, 0, sizeof(my_addr));
 			my_addr.sin_family = AF_INET;
 			my_addr.sin_port = htons(SS7_SLAVE_SERVER_PORT);




More information about the asterisk-commits mailing list