[Asterisk-cvs] asterisk asterisk.c,1.22,1.23

markster at lists.digium.com markster at lists.digium.com
Mon Sep 29 15:18:54 CDT 2003


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv19919

Modified Files:
	asterisk.c 
Log Message:
Check with select before accept (bug #325)


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- asterisk.c	17 Sep 2003 04:21:56 -0000	1.22
+++ asterisk.c	29 Sep 2003 20:20:04 -0000	1.23
@@ -216,6 +216,7 @@
 static void *listener(void *unused)
 {
 	struct sockaddr_un sun;
+	fd_set fds;
 	int s;
 	int len;
 	int x;
@@ -226,6 +227,13 @@
 	for(;;) {
 		if (ast_socket < 0)
 			return NULL;
+		FD_ZERO(&fds);
+		FD_SET(ast_socket, &fds);
+		s = ast_select(ast_socket + 1, &fds, NULL, NULL, NULL);
+		if (s < 0) {
+			ast_log(LOG_WARNING, "Select retured error: %s\n", strerror(errno));
+			continue;
+		}
 		len = sizeof(sun);
 		s = accept(ast_socket, (struct sockaddr *)&sun, &len);
 		if (s < 0) {




More information about the svn-commits mailing list