diff options
Diffstat (limited to 'threadproc')
-rw-r--r-- | threadproc/beos/thread.c | 6 | ||||
-rw-r--r-- | threadproc/netware/thread.c | 7 | ||||
-rw-r--r-- | threadproc/os2/thread.c | 12 | ||||
-rw-r--r-- | threadproc/unix/thread.c | 16 | ||||
-rw-r--r-- | threadproc/win32/thread.c | 16 |
5 files changed, 53 insertions, 4 deletions
diff --git a/threadproc/beos/thread.c b/threadproc/beos/thread.c index 80ec13a6d..15f1ca091 100644 --- a/threadproc/beos/thread.c +++ b/threadproc/beos/thread.c @@ -49,6 +49,12 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) return APR_NOTDETACH; } +APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, + apr_size_t stacksize) +{ + return APR_ENOTIMPL; +} + static void *dummy_worker(void *opaque) { apr_thread_t *thd = (apr_thread_t*)opaque; diff --git a/threadproc/netware/thread.c b/threadproc/netware/thread.c index 374b0d339..1703b55b1 100644 --- a/threadproc/netware/thread.c +++ b/threadproc/netware/thread.c @@ -50,6 +50,13 @@ apr_status_t apr_threadattr_detach_get(apr_threadattr_t *attr) return APR_NOTDETACH; } +APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, + apr_size_t stacksize) +{ + attr->stack_size = stacksize; + return APR_SUCCESS; +} + static void *dummy_worker(void *opaque) { apr_thread_t *thd = (apr_thread_t *)opaque; diff --git a/threadproc/os2/thread.c b/threadproc/os2/thread.c index d9cc23210..24b29f680 100644 --- a/threadproc/os2/thread.c +++ b/threadproc/os2/thread.c @@ -33,6 +33,7 @@ APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, apr_pool (*new)->pool = pool; (*new)->attr = 0; + (*new)->stacksize = 0; return APR_SUCCESS; } @@ -51,7 +52,12 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) return (attr->attr & APR_THREADATTR_DETACHED) ? APR_DETACH : APR_NOTDETACH; } - +APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, + apr_size_t stacksize) +{ + attr->stacksize = stacksize; + return APR_SUCCESS; +} static void apr_thread_begin(void *arg) { @@ -94,7 +100,9 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, apr_threadattr_t } thread->tid = _beginthread(apr_thread_begin, NULL, - APR_THREAD_STACKSIZE, thread); + thread->attr->stacksize > 0 ? + thread->attr->stacksize : APR_THREAD_STACKSIZE, + thread); if (thread->tid < 0) { return errno; diff --git a/threadproc/unix/thread.c b/threadproc/unix/thread.c index 6997e75df..00eee7ea3 100644 --- a/threadproc/unix/thread.c +++ b/threadproc/unix/thread.c @@ -78,6 +78,22 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) return APR_NOTDETACH; } +APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, + apr_size_t stacksize) +{ + int stat; + + stat = pthread_attr_setstacksize(&attr->attr, stacksize); + if (stat == 0) { + return APR_SUCCESS; + } +#ifdef PTHREAD_SETS_ERRNO + stat = errno; +#endif + + return stat; +} + static void *dummy_worker(void *opaque) { apr_thread_t *thread = (apr_thread_t*)opaque; diff --git a/threadproc/win32/thread.c b/threadproc/win32/thread.c index da36c3d83..92b6755a6 100644 --- a/threadproc/win32/thread.c +++ b/threadproc/win32/thread.c @@ -38,6 +38,9 @@ APR_DECLARE(apr_status_t) apr_threadattr_create(apr_threadattr_t **new, } (*new)->pool = pool; + (*new)->detach = 0; + (*new)->stacksize = 0; + return APR_SUCCESS; } @@ -55,6 +58,13 @@ APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr) return APR_NOTDETACH; } +APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr, + apr_size_t stacksize) +{ + attr->stacksize = stacksize; + return APR_SUCCESS; +} + static void *dummy_worker(void *opaque) { apr_thread_t *thd = (apr_thread_t *)opaque; @@ -89,13 +99,15 @@ APR_DECLARE(apr_status_t) apr_thread_create(apr_thread_t **new, * same size as the calling thread. */ #ifndef _WIN32_WCE - if (((*new)->td = (HANDLE)_beginthreadex(NULL, 0, + if (((*new)->td = (HANDLE)_beginthreadex(NULL, + attr && attr->stacksize > 0 ? attr->stacksize : 0, (unsigned int (APR_THREAD_FUNC *)(void *))dummy_worker, (*new), 0, &temp)) == 0) { return APR_FROM_OS_ERROR(_doserrno); } #else - if (((*new)->td = CreateThread(NULL, 0, + if (((*new)->td = CreateThread(NULL, + attr && attr->stacksize > 0 ? attr->stacksize : 0, (unsigned int (APR_THREAD_FUNC *)(void *))dummy_worker, (*new), 0, &temp)) == 0) { return apr_get_os_error(); |