You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2005/01/19 22:51:08 UTC

svn commit: r125670 - in apr/apr/branches/0.9.x: . include include/arch/os2 include/arch/win32 threadproc/beos threadproc/netware threadproc/os2 threadproc/unix threadproc/win32

Author: trawick
Date: Wed Jan 19 13:51:07 2005
New Revision: 125670

URL: http://svn.apache.org/viewcvs?view=rev&rev=125670
Log:
grab this feature from APR >= 1.0:

     Add apr_threadattr_stacksize_set() for overriding the default
     stack size for threads created by apr_thread_create().

Modified:
   apr/apr/branches/0.9.x/CHANGES
   apr/apr/branches/0.9.x/include/apr_thread_proc.h
   apr/apr/branches/0.9.x/include/arch/os2/apr_arch_threadproc.h
   apr/apr/branches/0.9.x/include/arch/win32/apr_arch_threadproc.h
   apr/apr/branches/0.9.x/threadproc/beos/thread.c
   apr/apr/branches/0.9.x/threadproc/netware/thread.c
   apr/apr/branches/0.9.x/threadproc/os2/thread.c
   apr/apr/branches/0.9.x/threadproc/unix/thread.c
   apr/apr/branches/0.9.x/threadproc/win32/thread.c

Modified: apr/apr/branches/0.9.x/CHANGES
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/CHANGES?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/CHANGES&r1=125669&p2=apr/apr/branches/0.9.x/CHANGES&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/CHANGES	(original)
+++ apr/apr/branches/0.9.x/CHANGES	Wed Jan 19 13:51:07 2005
@@ -1,5 +1,9 @@
 Changes with APR 0.9.6
 
+  *) Add apr_threadattr_stacksize_set() for overriding the default
+     stack size for threads created by apr_thread_create().
+     [Jeff Trawick]
+
   *) Add an RPM spec file. [Graham Leggett]
 
   *) Add a build script to create a solaris package. [Graham Leggett]

Modified: apr/apr/branches/0.9.x/include/apr_thread_proc.h
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/include/apr_thread_proc.h?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/include/apr_thread_proc.h&r1=125669&p2=apr/apr/branches/0.9.x/include/apr_thread_proc.h&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/include/apr_thread_proc.h	(original)
+++ apr/apr/branches/0.9.x/include/apr_thread_proc.h	Wed Jan 19 13:51:07 2005
@@ -219,6 +219,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 stacksize 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

Modified: apr/apr/branches/0.9.x/include/arch/os2/apr_arch_threadproc.h
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/include/arch/os2/apr_arch_threadproc.h?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/include/arch/os2/apr_arch_threadproc.h&r1=125669&p2=apr/apr/branches/0.9.x/include/arch/os2/apr_arch_threadproc.h&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/include/arch/os2/apr_arch_threadproc.h	(original)
+++ apr/apr/branches/0.9.x/include/arch/os2/apr_arch_threadproc.h	Wed Jan 19 13:51:07 2005
@@ -27,6 +27,7 @@
 struct apr_threadattr_t {
     apr_pool_t *pool;
     unsigned long attr;
+    apr_size_t stacksize;
 };
 
 struct apr_thread_t {

Modified: apr/apr/branches/0.9.x/include/arch/win32/apr_arch_threadproc.h
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/include/arch/win32/apr_arch_threadproc.h?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/include/arch/win32/apr_arch_threadproc.h&r1=125669&p2=apr/apr/branches/0.9.x/include/arch/win32/apr_arch_threadproc.h&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/include/arch/win32/apr_arch_threadproc.h	(original)
+++ apr/apr/branches/0.9.x/include/arch/win32/apr_arch_threadproc.h	Wed Jan 19 13:51:07 2005
@@ -35,6 +35,7 @@
 struct apr_threadattr_t {
     apr_pool_t *pool;
     apr_int32_t detach;
+    apr_size_t stacksize;
 };
 
 struct apr_threadkey_t {

Modified: apr/apr/branches/0.9.x/threadproc/beos/thread.c
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/threadproc/beos/thread.c?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/threadproc/beos/thread.c&r1=125669&p2=apr/apr/branches/0.9.x/threadproc/beos/thread.c&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/threadproc/beos/thread.c	(original)
+++ apr/apr/branches/0.9.x/threadproc/beos/thread.c	Wed Jan 19 13:51:07 2005
@@ -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;

Modified: apr/apr/branches/0.9.x/threadproc/netware/thread.c
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/threadproc/netware/thread.c?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/threadproc/netware/thread.c&r1=125669&p2=apr/apr/branches/0.9.x/threadproc/netware/thread.c&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/threadproc/netware/thread.c	(original)
+++ apr/apr/branches/0.9.x/threadproc/netware/thread.c	Wed Jan 19 13:51:07 2005
@@ -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;

Modified: apr/apr/branches/0.9.x/threadproc/os2/thread.c
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/threadproc/os2/thread.c?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/threadproc/os2/thread.c&r1=125669&p2=apr/apr/branches/0.9.x/threadproc/os2/thread.c&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/threadproc/os2/thread.c	(original)
+++ apr/apr/branches/0.9.x/threadproc/os2/thread.c	Wed Jan 19 13:51:07 2005
@@ -33,6 +33,7 @@
 
     (*new)->pool = pool;
     (*new)->attr = 0;
+    (*new)->stacksize = 0;
     return APR_SUCCESS;
 }
 
@@ -53,6 +54,15 @@
 
 
 
+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)
 {
   apr_thread_t *thread = (apr_thread_t *)arg;
@@ -93,8 +103,10 @@
         }
     }
 
-    thread->tid = _beginthread(apr_thread_begin, NULL, 
-                               APR_THREAD_STACKSIZE, thread);
+    thread->tid = _beginthread(apr_thread_begin, NULL,
+                               thread->attr->stacksize > 0 ?
+                               thread->attr->stacksize : APR_THREAD_STACKSIZE,
+                               thread);
         
     if (thread->tid < 0) {
         return errno;

Modified: apr/apr/branches/0.9.x/threadproc/unix/thread.c
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/threadproc/unix/thread.c?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/threadproc/unix/thread.c&r1=125669&p2=apr/apr/branches/0.9.x/threadproc/unix/thread.c&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/threadproc/unix/thread.c	(original)
+++ apr/apr/branches/0.9.x/threadproc/unix/thread.c	Wed Jan 19 13:51:07 2005
@@ -82,6 +82,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;

Modified: apr/apr/branches/0.9.x/threadproc/win32/thread.c
Url: http://svn.apache.org/viewcvs/apr/apr/branches/0.9.x/threadproc/win32/thread.c?view=diff&rev=125670&p1=apr/apr/branches/0.9.x/threadproc/win32/thread.c&r1=125669&p2=apr/apr/branches/0.9.x/threadproc/win32/thread.c&r2=125670
==============================================================================
--- apr/apr/branches/0.9.x/threadproc/win32/thread.c	(original)
+++ apr/apr/branches/0.9.x/threadproc/win32/thread.c	Wed Jan 19 13:51:07 2005
@@ -39,6 +39,7 @@
 
     (*new)->pool = pool;
     (*new)->detach = 0;
+    (*new)->stacksize = 0;
 
     return APR_SUCCESS;
 }
@@ -57,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;
@@ -93,13 +101,15 @@
      * same size as the calling thread. 
      */
 #ifndef _WIN32_WCE
-    if ((handle = (HANDLE)_beginthreadex(NULL, 0, 
+    if ((handle = (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 ((handle = CreateThread(NULL, 0, 
+   if ((handle = 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();