trawick 2004/03/01 13:05:44
Modified: . CHANGES
include apr_thread_proc.h
include/arch/os2 apr_arch_threadproc.h
include/arch/win32 apr_arch_threadproc.h
threadproc/beos thread.c
threadproc/netware thread.c
threadproc/os2 thread.c
threadproc/unix thread.c
threadproc/win32 thread.c
Log:
Add apr_threadattr_stacksize_set() for overriding the default
stack size for threads created by apr_thread_create().
This is currently a not-implemented stub for BeOS.
Revision Changes Path
1.452 +4 -0 apr/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apr/CHANGES,v
retrieving revision 1.451
retrieving revision 1.452
diff -u -r1.451 -r1.452
--- CHANGES 13 Feb 2004 09:38:23 -0000 1.451
+++ CHANGES 1 Mar 2004 21:05:44 -0000 1.452
@@ -7,6 +7,10 @@
Changes with APR 1.0
+ *) Add apr_threadattr_stacksize_set() for overriding the default
+ stack size for threads created by apr_thread_create().
+ [Jeff Trawick]
+
*) The whole codebase was relicensed and is now available under
the Apache License, Version 2.0 (http://www.apache.org/licenses).
[Apache Software Foundation]
1.102 +8 -0 apr/include/apr_thread_proc.h
Index: apr_thread_proc.h
===================================================================
RCS file: /home/cvs/apr/include/apr_thread_proc.h,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -r1.101 -r1.102
--- apr_thread_proc.h 13 Feb 2004 09:38:28 -0000 1.101
+++ apr_thread_proc.h 1 Mar 2004 21:05:44 -0000 1.102
@@ -216,6 +216,14 @@
APR_DECLARE(apr_status_t) apr_threadattr_detach_get(apr_threadattr_t *attr);
/**
+ * Set the stack size of newly created threads.
+ * @param attr The threadattr to affect
+ * @param on The stack size in bytes
+ */
+APR_DECLARE(apr_status_t) apr_threadattr_stacksize_set(apr_threadattr_t *attr,
+ apr_size_t stacksize);
+
+/**
* Create a new thread of execution
* @param new_thread The newly created thread handle.
* @param attr The threadattr to use to determine how to create the thread
1.3 +1 -0 apr/include/arch/os2/apr_arch_threadproc.h
Index: apr_arch_threadproc.h
===================================================================
RCS file: /home/cvs/apr/include/arch/os2/apr_arch_threadproc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- apr_arch_threadproc.h 13 Feb 2004 09:38:30 -0000 1.2
+++ apr_arch_threadproc.h 1 Mar 2004 21:05:44 -0000 1.3
@@ -27,6 +27,7 @@
struct apr_threadattr_t {
apr_pool_t *pool;
unsigned long attr;
+ apr_size_t stacksize;
};
struct apr_thread_t {
1.3 +1 -0 apr/include/arch/win32/apr_arch_threadproc.h
Index: apr_arch_threadproc.h
===================================================================
RCS file: /home/cvs/apr/include/arch/win32/apr_arch_threadproc.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- apr_arch_threadproc.h 13 Feb 2004 09:38:31 -0000 1.2
+++ apr_arch_threadproc.h 1 Mar 2004 21:05:44 -0000 1.3
@@ -35,6 +35,7 @@
struct apr_threadattr_t {
apr_pool_t *pool;
apr_int32_t detach;
+ apr_size_t stacksize;
};
struct apr_threadkey_t {
1.38 +6 -0 apr/threadproc/beos/thread.c
Index: thread.c
===================================================================
RCS file: /home/cvs/apr/threadproc/beos/thread.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- thread.c 13 Feb 2004 09:38:36 -0000 1.37
+++ thread.c 1 Mar 2004 21:05:44 -0000 1.38
@@ -49,6 +49,12 @@
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;
1.16 +7 -0 apr/threadproc/netware/thread.c
Index: thread.c
===================================================================
RCS file: /home/cvs/apr/threadproc/netware/thread.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- thread.c 13 Feb 2004 09:38:37 -0000 1.15
+++ thread.c 1 Mar 2004 21:05:44 -0000 1.16
@@ -50,6 +50,13 @@
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;
1.39 +10 -2 apr/threadproc/os2/thread.c
Index: thread.c
===================================================================
RCS file: /home/cvs/apr/threadproc/os2/thread.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- thread.c 13 Feb 2004 09:38:37 -0000 1.38
+++ thread.c 1 Mar 2004 21:05:44 -0000 1.39
@@ -33,6 +33,7 @@
(*new)->pool = pool;
(*new)->attr = 0;
+ (*new)->stacksize = 0;
return APR_SUCCESS;
}
@@ -51,7 +52,12 @@
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 @@
}
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;
1.57 +16 -0 apr/threadproc/unix/thread.c
Index: thread.c
===================================================================
RCS file: /home/cvs/apr/threadproc/unix/thread.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- thread.c 13 Feb 2004 09:38:37 -0000 1.56
+++ thread.c 1 Mar 2004 21:05:44 -0000 1.57
@@ -78,6 +78,22 @@
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;
1.56 +14 -2 apr/threadproc/win32/thread.c
Index: thread.c
===================================================================
RCS file: /home/cvs/apr/threadproc/win32/thread.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- thread.c 13 Feb 2004 09:38:38 -0000 1.55
+++ thread.c 1 Mar 2004 21:05:44 -0000 1.56
@@ -38,6 +38,9 @@
}
(*new)->pool = pool;
+ (*new)->detach = 0;
+ (*new)->stacksize = 0;
+
return APR_SUCCESS;
}
@@ -55,6 +58,13 @@
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 @@
* 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();
|