about summary refs log tree commit diff
path: root/linuxthreads/pthread.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-07-24 17:23:50 +0000
committerUlrich Drepper <drepper@redhat.com>2000-07-24 17:23:50 +0000
commit386bc781ae97a0c564b5387f592c2c1595bb0c9d (patch)
tree51de73bf281844d442fcd9a64caab212d6e4591f /linuxthreads/pthread.c
parentefd70b34d9c2a882297f8824b906b95b2646042f (diff)
downloadglibc-386bc781ae97a0c564b5387f592c2c1595bb0c9d.tar.gz
glibc-386bc781ae97a0c564b5387f592c2c1595bb0c9d.tar.xz
glibc-386bc781ae97a0c564b5387f592c2c1595bb0c9d.zip
(__pthread_initial_thread): Update initializer. (__pthread_manager_thread): Likewise. (pthread_initialize): Move setrlimit call to... (__pthread_initialize_manager): ...here. (__pthread_reset_main_thread): Reset also soft limit on stack size.
Diffstat (limited to 'linuxthreads/pthread.c')
-rw-r--r--linuxthreads/pthread.c41
1 files changed, 25 insertions, 16 deletions
diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c
index 551086f84b..1d93366380 100644
--- a/linuxthreads/pthread.c
+++ b/linuxthreads/pthread.c
@@ -82,6 +82,7 @@ struct _pthread_descr_struct __pthread_initial_thread = {
   {{{0, }}, 0, NULL},         /* td_eventbuf_t p_eventbuf */
   ATOMIC_INITIALIZER,         /* struct pthread_atomic p_resume_count */
   0,                          /* char p_woken_by_cancel */
+  0,                          /* char p_condvar_avail */
   NULL,                       /* struct pthread_extricate_if *p_extricate */
   NULL,	                      /* pthread_readlock_info *p_readlock_list; */
   NULL,                       /* pthread_readlock_info *p_readlock_free; */
@@ -137,6 +138,7 @@ struct _pthread_descr_struct __pthread_manager_thread = {
   {{{0, }}, 0, NULL},         /* td_eventbuf_t p_eventbuf */
   ATOMIC_INITIALIZER,         /* struct pthread_atomic p_resume_count */
   0,                          /* char p_woken_by_cancel */
+  0,                          /* char p_condvar_avail */
   NULL,                       /* struct pthread_extricate_if *p_extricate */
   NULL,	                      /* pthread_readlock_info *p_readlock_list; */
   NULL,                       /* pthread_readlock_info *p_readlock_free; */
@@ -377,8 +379,6 @@ static void pthread_initialize(void)
 {
   struct sigaction sa;
   sigset_t mask;
-  struct rlimit limit;
-  int max_stack;
 
   /* If already done (e.g. by a constructor called earlier!), bail out */
   if (__pthread_initial_thread_bos != NULL) return;
@@ -393,20 +393,6 @@ static void pthread_initialize(void)
     (char *)(((long)CURRENT_STACK_FRAME - 2 * STACK_SIZE) & ~(STACK_SIZE - 1));
   /* Update the descriptor for the initial thread. */
   __pthread_initial_thread.p_pid = __getpid();
-  /* Play with the stack size limit to make sure that no stack ever grows
-     beyond STACK_SIZE minus one page (to act as a guard page). */
-  getrlimit(RLIMIT_STACK, &limit);
-#ifdef NEED_SEPARATE_REGISTER_STACK
-  /* STACK_SIZE bytes hold both the main stack and register backing
-     store. The rlimit value applies to each individually.  */
-  max_stack = STACK_SIZE/2 - __getpagesize();
-#else
-  max_stack = STACK_SIZE - __getpagesize();
-#endif
-  if (limit.rlim_cur > max_stack) {
-    limit.rlim_cur = max_stack;
-    setrlimit(RLIMIT_STACK, &limit);
-  }
   /* Likewise for the resolver state _res.  */
   __pthread_initial_thread.p_resp = &_res;
 #ifdef __SIGRTMIN
@@ -457,7 +443,23 @@ int __pthread_initialize_manager(void)
   int manager_pipe[2];
   int pid;
   struct pthread_request request;
+  struct rlimit limit;
+  int max_stack;
 
+  /* Play with the stack size limit to make sure that no stack ever grows
+     beyond STACK_SIZE minus one page (to act as a guard page). */
+  getrlimit(RLIMIT_STACK, &limit);
+#ifdef NEED_SEPARATE_REGISTER_STACK
+  /* STACK_SIZE bytes hold both the main stack and register backing
+     store. The rlimit value applies to each individually.  */
+  max_stack = STACK_SIZE/2 - __getpagesize();
+#else
+  max_stack = STACK_SIZE - __getpagesize();
+#endif
+  if (limit.rlim_cur > max_stack) {
+    limit.rlim_cur = max_stack;
+    setrlimit(RLIMIT_STACK, &limit);
+  }
   /* If basic initialization not done yet (e.g. we're called from a
      constructor run before our constructor), do it now */
   if (__pthread_initial_thread_bos == NULL) pthread_initialize();
@@ -787,6 +789,7 @@ static void pthread_handle_sigdebug(int sig)
 void __pthread_reset_main_thread()
 {
   pthread_descr self = thread_self();
+  struct rlimit limit;
 
   if (__pthread_manager_request != -1) {
     /* Free the thread manager stack */
@@ -808,6 +811,12 @@ void __pthread_reset_main_thread()
   THREAD_SETMEM(self, p_errnop, &_errno);
   THREAD_SETMEM(self, p_h_errnop, &_h_errno);
   THREAD_SETMEM(self, p_resp, &_res);
+
+  if (getrlimit (RLIMIT_STACK, &limit) == 0
+      && limit.rlim_cur != limit.rlim_max) {
+    limit.rlim_cur = limit.rlim_max;
+    setrlimit (STACK_SIZE, &limit);
+  }
 }
 
 /* Process-wide exec() request */