Make stack size be selectable
authorMark Spencer <markster@digium.com>
Fri, 4 Mar 2005 00:01:41 +0000 (00:01 +0000)
committerMark Spencer <markster@digium.com>
Fri, 4 Mar 2005 00:01:41 +0000 (00:01 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5132 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/utils.h
utils.c

index c09aa6e..e2585e5 100755 (executable)
@@ -161,11 +161,11 @@ struct ast_realloca {
 #define inet_ntoa __dont__use__inet_ntoa__use__ast_inet_ntoa__instead__
 
 #define AST_STACKSIZE 128 * 1024
-
+#define ast_pthread_create(a,b,c,d) ast_pthread_create_stack(a,b,c,d,0)
 #ifdef __linux__
 #define ast_strcasestr strcasestr
 #else
 extern char *ast_strcasestr(const char *, const char *);
 #endif /* __linux__ */
-extern int ast_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data);
+extern int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize);
 #endif
diff --git a/utils.c b/utils.c
index 6267bbb..3e9ddf6 100755 (executable)
--- a/utils.c
+++ b/utils.c
@@ -389,14 +389,16 @@ int ast_utils_init(void)
 }
 
 
-int ast_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data)
+int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *data, size_t stacksize)
 {
        pthread_attr_t lattr;
        if (!attr) {
                pthread_attr_init(&lattr);
                attr = &lattr;
        }
-       errno = pthread_attr_setstacksize(attr, AST_STACKSIZE);
+       if (!stacksize)
+               stacksize = AST_STACKSIZE;
+       errno = pthread_attr_setstacksize(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 */