diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-11-08 14:28:26 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2013-11-09 19:14:34 +0100 |
commit | 9019e629679ec12c1a4c9656bab337e84f861e8c (patch) | |
tree | a1d9e06faf460c1ec89667d18b4fd00441dc3629 /libports/manage-multithread.c | |
parent | 057c04d1157322c235872e412bcc22487858c5af (diff) |
libports: fix the thread counts in case the thread creation fails
Previously the number of total threads and the number of unused
threads was wrong if at one point the creation of a thread failed. Fix
this by decrementing both counters that were previously optimistically
incremented. Adjust the comment accordingly.
* libports/manage-multithread.c (ports_manage_port_operations_multithread):
Fix the thread counts in case the thread creation fails.
Diffstat (limited to 'libports/manage-multithread.c')
-rw-r--r-- | libports/manage-multithread.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/libports/manage-multithread.c b/libports/manage-multithread.c index 60f4c19d..0c2da005 100644 --- a/libports/manage-multithread.c +++ b/libports/manage-multithread.c @@ -140,9 +140,13 @@ ports_manage_port_operations_multithread (struct port_bucket *bucket, pthread_detach (pthread_id); else { - /* XXX The number of threads should be adjusted but the code - and design of the Hurd servers just don't handle thread - creation failure. */ + pthread_spin_lock (&lock); + totalthreads--; + nreqthreads--; + pthread_spin_unlock (&lock); + /* There is not much we can do at this point. The code + and design of the Hurd servers just don't handle + thread creation failure. */ errno = err; perror ("pthread_create"); } |