Commit Graph

87 Commits

Author SHA1 Message Date
Kurt Zeilenga
c890c96d13 Happy New Year (belated) 2008-01-08 00:19:56 +00:00
Pierangelo Masarati
30f401c628 rename ldap_pvt_thread_pool_setkey_x() to ldap_pvt_thread_pool_setkey() (as part of ITS#5309) 2008-01-07 21:35:03 +00:00
Pierangelo Masarati
622c4d3884 new ldap_pvt_thread_pool_setkey API 2007-12-29 18:14:54 +00:00
Howard Chu
a354d38fea Fix typo in prev commit 2007-10-25 06:50:43 +00:00
Howard Chu
183ff5120c Use thread-specific data in pool_context() 2007-10-25 06:48:44 +00:00
Howard Chu
20c4e016fa Added native thread-specific data support 2007-10-25 06:42:40 +00:00
Howard Chu
13c6ef95ce ITS#5194 zero out pool when destroying 2007-10-18 21:13:43 +00:00
Howard Chu
6775e25ba3 In pool_resume don't touch the condvar if the pool is tearing down. 2007-10-18 06:52:54 +00:00
Howard Chu
a1a63bead0 ITS#4188 check for pool pause every 64 entries. (probably should make
this number tunable.)
2007-10-08 01:15:49 +00:00
Hallvard Furuseth
2ea3d3f621 Ensure ltp_max_pending >= 0; negative values confused pool_query().
Remove accidentally added #define LDAP_MAX_PENDING from last commit.
2007-07-03 11:34:14 +00:00
Hallvard Furuseth
bc8631183c Remove bogus pause wait near end of pool_wrapper(). Add/fix comments. 2007-07-01 16:44:59 +00:00
Hallvard Furuseth
ed0c9d223a Rename thread contexts to tasks, leaving user contexts the only context.
Remove ldap_int_thread_ctx_t.ltc_next.al (active list) left over from rev 1.75.
2007-06-10 23:58:38 +00:00
Hallvard Furuseth
c60f7c1fd2 For ITS#4943: Axe thread pool semaphore code 2007-06-10 23:37:49 +00:00
Hallvard Furuseth
b327239618 Remove ltp_active_list. It became unneeded when rev 1.24 added thread_keys[].
Tighten loop in pool_pause(): Omit unneeded ltp_pcond signals since rev 1.64.
Fix comment.
2007-06-04 22:18:01 +00:00
Hallvard Furuseth
b3e4305131 Simplify: Remove tid_zero, thread_keys[].id and ldap_int_main_tid.
Not needed after ldap_int_thread_userctx_t.ltu_id was added and
_pool_wrapper took care not to update thread_keys[] during pauses.
Fix bogus thread_keys[].ctx comment.
2007-06-01 15:24:19 +00:00
Hallvard Furuseth
1b890689b1 Add comments. Constify tid_zero. Shut up gcc -Wswitch. if(!tpool)->assert(). 2007-05-31 19:47:38 +00:00
Hallvard Furuseth
1f3e6110b9 Add variable ldap_int_has_thread_pool, assert(at most one pool); 2007-05-31 17:15:54 +00:00
Hallvard Furuseth
1b15fa9c6e In pool_submit():
- Move problematic mutex_unlock()-mutex_lock() into the unused #ifdef
  LDAP_PVT_THREAD_POOL_SEM_LOAD_CONTROL and add a FIXME comment inside.
- Delay ltp_starting--; until pool_wrapper().  Nonzero value could otherwise
  no longer be exposed when !defined LDAP_PVT_THREAD_POOL_SEM_LOAD_CONTROL.
2007-05-31 12:47:24 +00:00
Hallvard Furuseth
45389c0341 Preserve key order when deleting, so context_reset will free last keys first. 2007-05-31 12:08:50 +00:00
Hallvard Furuseth
e509d3ed9a Comment fixes.
Corrected rev 1.67 cvs comment: ltu_key[] is NULL-terminated _when not full_.
2007-05-11 18:48:13 +00:00
Hallvard Furuseth
810b2389dc Since we only have LDAP_MAXTHR thread_keys, allow max LDAP_MAXTHR
threads per pool, even when ltp_max_count <= 0 ("unlimited").
Keep ltp_max_count in range [0, LDAP_MAXTHR].
2007-05-09 23:25:03 +00:00
Hallvard Furuseth
f0a1511422 Make ldap_int_thread_userctx_t.ltu_key[] a proper NULL-terminated array.
(setkey/getkey expected that, but purgekey could set a NULL in the middle.)
Added some checks for input key!=NULL.

API changes, need review - I'm not sure what's indented here:
- setkey(data=NULL, kfree!=NULL) searched as if intended to reset
  the key, but updated by setting the key.  Now always updates.
- setkey(key=<not found>, data=NULL) could return either success or
  failure.  Now succeeds iff (data == NULL && kfree == NULL).
2007-05-09 22:59:04 +00:00
Hallvard Furuseth
f5da908c49 thread_keys is a (poor) open-addessed hash table, but it lacked a
"deleted item" mark.  Add DELETED_THREAD_CTX.
Also improve the hash function a bit, and make the hash unsigned.
2007-05-09 22:22:44 +00:00
Hallvard Furuseth
8a92825225 Protect thread_keys[] with ldap_pvt_thread_pool_mutex, except in
ldap_pvt_thread_pool_purgekey() which may only be called during pauses.

Thus, also wait for pauses to finish before accessing thread_keys in
ldap_int_thread_pool_wrapper().  This may prevent pending tasks from
being started when a pause had been requested, which seems to have been
possible.  If that was a feature, we can split ltp_pause==1 in 2 states:
in pause (causes wait), and pause requested.

Also move 'thread_keys[].id = <thread id>' from pool_submit to
pool_wrapper.  Until pool_wrapper set the ctx as well, thread context
lookup would just return NULL anyway.
2007-05-09 21:38:28 +00:00
Hallvard Furuseth
92afeb8ef7 Replace state LDAP_INT_THREAD_POOL_PAUSING with member ltp_pause,
so a pause will work during states FINISHING and STOPPING.

Add missing waits and signals, and move waits in pool_wrapper().
Replace if(test) with while(test) when waiting for the multi-purpose
condition variable ltp_cond.
2007-05-09 19:53:25 +00:00
Hallvard Furuseth
9e9bf22a64 ITS#4943:
In ldap_pvt_thread_pool_submit(), when backing out of thread creation:
  ltp_pending_count '++' -> '--'.  Signal if there are no more threads.
In ldap_int_thread_pool_wrapper():
  if() -> assert() where false would result in eternal loop.
2007-05-09 19:34:49 +00:00
Howard Chu
28493e554c ITS#4912 fix typo in prev commit 2007-04-05 00:16:17 +00:00
Howard Chu
c80d5f970a ITS#4899 fix for keys not getting cleared 2007-04-01 11:52:51 +00:00
Howard Chu
f97f109483 Fix prev commit again 2007-01-28 02:12:29 +00:00
Howard Chu
99a8deb160 ITS#4821 partially revert prev patch 2007-01-27 18:40:02 +00:00
Howard Chu
977bd839cc Calling setkey() with NULL data and kfree should erase the key. 2007-01-25 11:53:09 +00:00
Howard Chu
2298595ea3 Free thread keys in reverse order of allocation 2007-01-25 11:13:15 +00:00
Kurt Zeilenga
da6d9eb046 happy new year 2007-01-02 20:00:42 +00:00
Pierangelo Masarati
67f3fd8078 monitor __ALL__ thread parameters 2006-09-14 18:55:02 +00:00
Howard Chu
f269301ab9 Add ldap_pvt_thread_pool_tid() 2006-05-02 00:56:42 +00:00
Howard Chu
5b8a74590b Fix tpool_shutdown, don't remove pool from list since pool_destroy
already does it.
2006-04-29 22:31:58 +00:00
Hallvard Furuseth
da0c0360e4 Warnings: Unused vars. funcptr=0, not =NULL. if(b=...) -> if((b=...) != NULL). 2006-04-02 19:54:24 +00:00
Howard Chu
9870eba3ee ITS#4368 unlock pool ltp_mutex before destroying it 2006-01-24 23:31:56 +00:00
Howard Chu
84315e96f8 ITS#4349 don't wait on condition if there are no threads in the pool. 2006-01-18 01:55:24 +00:00
Howard Chu
7f5ea4c098 Get rid of trivial yield, for completeness' sake. 2006-01-15 14:34:44 +00:00
Howard Chu
78a9d66e53 ITS#3950 delete gratuitous yield. (could use pthread_cond_timedwait
if we ever wanted to time out idle threads.)
2006-01-15 14:21:16 +00:00
Kurt Zeilenga
acbb5cf689 Happy new year! 2006-01-03 23:11:52 +00:00
Howard Chu
f80e9d11fa Fix prev commit, spawns unnecessary threads. 2005-10-28 10:31:21 +00:00
Howard Chu
71514ffb92 Fix pool_submit, create threads as long as we're under the max count. 2005-10-27 21:55:18 +00:00
Pierangelo Masarati
d277c5b3d6 silence SLAP_SEM_LOAD_CONTROL related warnings... 2005-10-16 08:58:06 +00:00
Kurt Zeilenga
533394d641 disable SLAP_SEM_LOAD_CONTROL by default, needs additional review/work
Misc. other cleanup
2005-10-16 00:17:58 +00:00
Kurt Zeilenga
6db7e605ee Align Operation buffers using LBER_ALIGNED_BUFFER 2005-10-12 23:17:28 +00:00
Hallvard Furuseth
123948bd5e Add thread debugging wrapper thr_debug.c and ldap_thr_debug.h in libldap_r/,
enabled with LDAP_THREAD_DEBUG (cpp macro and environment variable):

Move any ldap_pvt_* definitions from ldap_int_thread.h to ldap_pvt_thread.h.
#define ldap_int_thread_equal/ldap_pvt_thread_equal instead of tpool.c:TID_EQ.
Define some ldap_debug_*_t types, and LDAP_UINTPTR_T, in ldap_int_thread.h.
ldap_int_thread.h/ldap_pvt_thread.h can now be included multiple times, giving
different results depending on whether libldap_r/ldap_thr_debug.h was included.
Add some cleanup and some preprocessor hacks.
#define LDAP_THREAD*_IMPLEMENTATION in libldap_r/*.c, used by ldap_thr_debug.h.
Add PTHREAD_MUTEX_ERRORCHECK/PTHREAD_MUTEX_ERRORCHECK_NP in thr_posix.c.
2005-09-17 23:28:08 +00:00
Pierangelo Masarati
6aa5b4f775 address ITS#3925; please test 2005-09-01 01:59:36 +00:00
Pierangelo Masarati
fe4b006e17 wait also if PAUSING; silence warnings and improve readability with gdb 2005-09-01 01:54:00 +00:00