[Asterisk-cvs] asterisk asterisk.c,1.114,1.115 autoservice.c,1.6,1.7 manager.c,1.66,1.67 pbx.c,1.143,1.144 utils.c,1.15,1.16

markster at lists.digium.com markster at lists.digium.com
Sun Aug 8 13:29:02 CDT 2004


Update of /usr/cvsroot/asterisk
In directory localhost.localdomain:/tmp/cvs-serv18773

Modified Files:
	asterisk.c autoservice.c manager.c pbx.c utils.c 
Log Message:
Merge BSD stack size work (bug #2067)


Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- asterisk.c	7 Aug 2004 14:22:09 -0000	1.114
+++ asterisk.c	8 Aug 2004 17:15:01 -0000	1.115
@@ -342,7 +342,7 @@
 					flags = fcntl(consoles[x].p[1], F_GETFL);
 					fcntl(consoles[x].p[1], F_SETFL, flags | O_NONBLOCK);
 					consoles[x].fd = s;
-					if (pthread_create(&consoles[x].t, &attr, netconsole, &consoles[x])) {
+					if (ast_pthread_create(&consoles[x].t, &attr, netconsole, &consoles[x])) {
 						ast_log(LOG_ERROR, "Unable to spawn thread to handle connection: %s\n", strerror(errno));
 						consoles[x].fd = -1;
 						fdprint(s, "Server failed to spawn thread\n");
@@ -395,7 +395,7 @@
 		return -1;
 	}
 	ast_register_verbose(network_verboser);
-	pthread_create(&lthread, NULL, listener, NULL);
+	ast_pthread_create(&lthread, NULL, listener, NULL);
 	return 0;
 }
 

Index: autoservice.c
===================================================================
RCS file: /usr/cvsroot/asterisk/autoservice.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- autoservice.c	22 Jun 2004 18:48:59 -0000	1.6
+++ autoservice.c	8 Aug 2004 17:15:01 -0000	1.7
@@ -33,6 +33,7 @@
 #include <asterisk/linkedlists.h>
 #include <asterisk/indications.h>
 #include <asterisk/lock.h>
+#include <asterisk/utils.h>
 
 #define MAX_AUTOMONS 256
 
@@ -106,7 +107,7 @@
 			aslist = as;
 			res = 0;
 			if (needstart) {
-				if (pthread_create(&asthread, NULL, autoservice_run, NULL)) {
+				if (ast_pthread_create(&asthread, NULL, autoservice_run, NULL)) {
 					ast_log(LOG_WARNING, "Unable to create autoservice thread :(\n");
 					free(aslist);
 					aslist = NULL;

Index: manager.c
===================================================================
RCS file: /usr/cvsroot/asterisk/manager.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- manager.c	3 Aug 2004 17:48:18 -0000	1.66
+++ manager.c	8 Aug 2004 17:15:01 -0000	1.67
@@ -886,7 +886,7 @@
 			fast->priority = pi;
 			pthread_attr_init(&attr);
 			pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-			if (pthread_create(&th, &attr, fast_originate, fast))
+			if (ast_pthread_create(&th, &attr, fast_originate, fast))
 			{
 				res = -1;
 			}
@@ -1216,7 +1216,7 @@
 		s->next = sessions;
 		sessions = s;
 		ast_mutex_unlock(&sessionlock);
-		if (pthread_create(&t, &attr, session_do, s))
+		if (ast_pthread_create(&t, &attr, session_do, s))
 			destroy_session(s);
 	}
 	pthread_attr_destroy(&attr);
@@ -1448,7 +1448,7 @@
 		}
 		if (option_verbose)
 			ast_verbose("Asterisk Management interface listening on port %d\n", portno);
-		pthread_create(&t, NULL, accept_thread, NULL);
+		ast_pthread_create(&t, NULL, accept_thread, NULL);
 	}
 	return 0;
 }

Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.143
retrieving revision 1.144
diff -u -d -r1.143 -r1.144
--- pbx.c	3 Aug 2004 06:31:20 -0000	1.143
+++ pbx.c	8 Aug 2004 17:15:01 -0000	1.144
@@ -1985,7 +1985,7 @@
 	/* Start a new thread, and get something handling this channel. */
 	pthread_attr_init(&attr);
 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-	if (pthread_create(&t, &attr, pbx_thread, c)) {
+	if (ast_pthread_create(&t, &attr, pbx_thread, c)) {
 		ast_log(LOG_WARNING, "Failed to create new channel thread\n");
 		return -1;
 	}
@@ -4041,7 +4041,7 @@
 		}
 		pthread_attr_init(&attr);
 		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-		if (pthread_create(&as->p, &attr, async_wait, as)) {
+		if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
 			ast_log(LOG_WARNING, "Failed to start async wait\n");
 			free(as);
 			ast_hangup(chan);
@@ -4111,7 +4111,7 @@
 					} else {
 						pthread_attr_init(&attr);
 						pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-						if (pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) {
+						if (ast_pthread_create(&tmp->t, &attr, ast_pbx_run_app, tmp)) {
 							ast_log(LOG_WARNING, "Unable to spawn execute thread on %s: %s\n", chan->name, strerror(errno));
 							free(tmp);
 							ast_hangup(chan);
@@ -4152,7 +4152,7 @@
 		/* Start a new thread, and get something handling this channel. */
 		pthread_attr_init(&attr);
 		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-		if (pthread_create(&as->p, &attr, async_wait, as)) {
+		if (ast_pthread_create(&as->p, &attr, async_wait, as)) {
 			ast_log(LOG_WARNING, "Failed to start async wait\n");
 			free(as);
 			ast_hangup(chan);

Index: utils.c
===================================================================
RCS file: /usr/cvsroot/asterisk/utils.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- utils.c	29 Jun 2004 17:54:25 -0000	1.15
+++ utils.c	8 Aug 2004 17:15:01 -0000	1.16
@@ -12,12 +12,14 @@
 #include <ctype.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <asterisk/lock.h>
 #include <asterisk/utils.h>
+#include <asterisk/logger.h>
 
 static char base64[64];
 static char b2a[256];
@@ -197,7 +199,7 @@
 	lock_count += 1;
 	ast_mutex_lock(&test_lock);
 	lock_count += 1;
-	pthread_create(&test_thread, NULL, test_thread_body, NULL); 
+	ast_pthread_create(&test_thread, NULL, test_thread_body, NULL); 
 	usleep(100);
 	if (lock_count != 2) 
 		test_errors++;
@@ -344,3 +346,20 @@
 	base64_init();
 	return 0;
 }
+
+
+#ifndef LINUX
+#undef pthread_create /* For ast_pthread_create function only */
+int ast_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data)
+{
+	pthread_attr_t lattr;
+	if (!attr) {
+		pthread_attr_init(&lattr);
+		attr = &lattr;
+	}
+	errno = pthread_attr_setstacksize(attr, PTHREAD_ATTR_STACKSIZE);
+	if (errno)
+		ast_log(LOG_WARNING, "pthread_attr_setstacksize returned non-zero: %s\n", strerror(errno));
+	return pthread_create(thread, attr, start_routine, data); /* We're in ast_pthread_create, so it's okay */
+}
+#endif /* ! LINUX */




More information about the svn-commits mailing list