about summary refs log tree commit diff
path: root/nptl/pthread_setspecific.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-04-02 03:51:24 +0000
committerUlrich Drepper <drepper@redhat.com>2003-04-02 03:51:24 +0000
commit6b4686a534c10cc9011c9d352d1b57d5a76d5579 (patch)
treef83ff4ca255084c741620875883da8ce4823d7a5 /nptl/pthread_setspecific.c
parentfa36efe8931c7e0dc8c7bf6973d97de32bddd6d4 (diff)
downloadglibc-6b4686a534c10cc9011c9d352d1b57d5a76d5579.tar.gz
glibc-6b4686a534c10cc9011c9d352d1b57d5a76d5579.tar.xz
glibc-6b4686a534c10cc9011c9d352d1b57d5a76d5579.zip
Update.
2003-04-01  Ulrich Drepper  <drepper@redhat.com>

	* pthread_create.c (deallocate_tsd): Clear/free memory after the last
	round, not the first.  Use specific_used flag instead of local
	found_nonzero variable.  Use THREAD_[SG]ETMEM where possible.
	(__free_tcb): Don't call deallocate_tsd here.
	(start_thread): Call deallocate_tsd here.
	* pthread_setspecific.c: Set specific_used flag really only when
	needed.
	* Makefile (tests): Add tst-tsd3.c
	* tst-tsd3.c: New file.
Diffstat (limited to 'nptl/pthread_setspecific.c')
-rw-r--r--nptl/pthread_setspecific.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/nptl/pthread_setspecific.c b/nptl/pthread_setspecific.c
index baca804adb..b6e66b5f22 100644
--- a/nptl/pthread_setspecific.c
+++ b/nptl/pthread_setspecific.c
@@ -45,6 +45,10 @@ __pthread_setspecific (key, value)
 	return EINVAL;
 
       level2 = &self->specific_1stblock[key];
+
+      /* Remember that we stored at least one set of data.  */
+      if (value != NULL)
+	THREAD_SETMEM (self, specific_used, true);
     }
   else
     {
@@ -76,6 +80,9 @@ __pthread_setspecific (key, value)
 
       /* Pointer to the right array element.  */
       level2 = &level2[idx2nd];
+
+      /* Remember that we stored at least one set of data.  */
+      THREAD_SETMEM (self, specific_used, true);
     }
 
   /* Store the data and the sequence number so that we can recognize
@@ -83,9 +90,6 @@ __pthread_setspecific (key, value)
   level2->seq = seq;
   level2->data = (void *) value;
 
-  /* Remember that we stored at least one set of data.  */
-  THREAD_SETMEM (self, specific_used, true);
-
   return 0;
 }
 strong_alias (__pthread_setspecific, pthread_setspecific)