Merge BSD stack size work (bug #2067)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@3596 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2004-08-08 17:15:02 +00:00
parent 916566ac11
commit 7acee329e1
29 changed files with 101 additions and 58 deletions

21
utils.c
View File

@@ -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 @@ int test_for_thread_safety(void)
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 @@ int ast_utils_init(void)
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 */