Commit Graph

327 Commits

Author SHA1 Message Date
Pierangelo Masarati
7e3c9a07e9 add client API for assertion control (ITS#5560) 2008-06-14 17:49:47 +00:00
Howard Chu
ce27143ce7 ITS#5519 add missing stubs 2008-05-20 11:23:19 +00:00
Hallvard Furuseth
00be565264 ITS#5407 cleanup (make pool_pause & pool_pausecheck wrappers for handle_pause) 2008-03-10 13:21:24 +00:00
Howard Chu
a287573d2d ITS#5407 more checks for pool pausing 2008-03-08 23:51:07 +00:00
Hallvard Furuseth
7859063553 ITS#5364 cleanup
Fix rev 1.91 patch: Reset ltp_pending_count when flushing ltp_pending_list.
Remove flush_pending_list() again and the now-unnecessary 2nd call to it.
Help the compiler a little.
Move ltp_work_list in case it makes a difference for caching.
Move mutex unlock in pool_destroy() to make concurrency debuggers happier.
2008-02-11 15:49:52 +00:00
Hallvard Furuseth
650aaee3a5 ITS#5364, reduce work with ltp_mutex locked:
Negate ltp_open_count when paused, avoids an ltp_pause test in pool_submit().
2008-02-10 18:16:44 +00:00
Hallvard Furuseth
8afd0b05c1 ITS#5364: introduce ltp_work_list, drop 1st ltp_pause loop in pool_wrapper(). 2008-02-10 17:55:13 +00:00
Hallvard Furuseth
fe86a1cbe5 ITS#5364: maintain value ltp_vary_open_count 2008-02-10 17:38:32 +00:00
Hallvard Furuseth
ee73fca523 ITS#5364, reduce work with ltp_mutex locked:
Replace ltp_state with ltp_finishing.  Drop state
LDAP_INT_THREAD_POOL_STOPPING, flush pending list instead.
ltp_max_pending = default value instead of 0, and negative when finishing.
2008-02-10 17:28:20 +00:00
Hallvard Furuseth
6dd87bb83f ITS#5364, thread pool efficiency:
Add ldap_pvt_thread_pool_pausing(): pause check for slapd without locking.
Make counters int instead of long; INT_MAX pending tasks is enough.
Nitpick cleanup: goto failure instead of if() to not-failure in _submit().
2008-02-10 16:15:30 +00:00
Hallvard Furuseth
cd63a0c43b Warning cleanup: function ptr <=> void* at ldap_pvt_thread_pool_<set/get>key() 2008-01-11 06:07:43 +00:00
Hallvard Furuseth
ac914f96a0 #include <signal.h> for pthread_kill() 2008-01-10 16:24:07 +00:00
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
Hallvard Furuseth
4a2cda3cff ITS#5309: complete the addition of ldap_pvt_thread_pool_setkey_x() 2008-01-07 20:04:46 +00:00
Pierangelo Masarati
622c4d3884 new ldap_pvt_thread_pool_setkey API 2007-12-29 18:14:54 +00:00
Quanah Gibson-Mount
afcc7d9e83 ITS#4982 libldap_r threaded library linking 2007-12-21 22:18:35 +00:00
Kurt Zeilenga
ac7762996e Reverse last commit (made by mistake) 2007-11-27 20:49:47 +00:00
Kurt Zeilenga
9c970bdb21 OpenLDAP Devel README
This software was obtained from the development branch (HEAD) of
	the OpenLDAP Software Repository.  This copy is likely already
	not current, the development branch changes frequently.  These
	changes include code implementing experimental features and
	unproven bug fixes.  Please do NOT redistribute copies of the
	development branch.

	The OpenLDAP Developer's FAQ is available at:
		<http://www.openldap.org/faq/index.cgi?file=4>

	Client developers seeking a suitable development platform
	should use "release" or "stable" versions.
		<http://www.openldap.org/software/>

Contributing
	See <http://www.openldap.org/devel/contributing.html> for how to
	contribute code or documentation to OpenLDAP.  Use the Issue Tracking
	System <http://www.openldap.org/its/> to submit contributions.
	While you are encouraged to coordinate and discuss the development
	activities on the openldap-devel@openldap.org mailing list prior
	to submission, it is noted that contributions must be submitted
	using the Issue Tracking System to be considered.

---
$OpenLDAP: pkg/ldap/README,v 1.45 2007/03/10 17:03:58 kurt Exp $

This work is part of OpenLDAP Software <http://www.openldap.org/>.

Copyright 1998-2007 The OpenLDAP Foundation.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted only as authorized by the OpenLDAP
Public License.

A copy of this license is available in the file LICENSE in the
top-level directory of the distribution or, alternatively, at
<http://www.OpenLDAP.org/license.html>.

OpenLDAP is a registered trademark of the OpenLDAP Foundation.
2007-11-27 20:48:38 +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
9bc4ebd12c ITS#5197 add stub for ldap_pvt_thread_pool_query() 2007-10-23 21:14:11 +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
Pierangelo Masarati
b0d2063d92 client side of draft-wahl-ldap-session 2007-08-21 23:52:03 +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
7c6b26a68f Make get_thread_info() static. Handle ldap_pvt_thread_pool_t = int (not ptr). 2007-05-30 22:20:20 +00:00
Hallvard Furuseth
eb351d9e33 ITS#4972: $LDAP_THREAD_DEBUG, detached threads, debug_already_initialized().
Also plug a memory leak, set state vars even when unused for the sake of
debugging, and tweak some readability issues & data types.
2007-05-18 17:49:38 +00:00
Hallvard Furuseth
6f3cf907b8 Readability patch: ERRVAL() macro for pthreads < 7 vs. >= 7 return values. 2007-05-18 15:28:09 +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
Hallvard Furuseth
bb890724d4 Don't complain if detached threads exit after ldap_debug_thread_destroy(). 2007-05-09 19:21:08 +00:00
Hallvard Furuseth
bbc719ca56 ITS#4948: '#if <undefined macro>' -> '#ifdef' warning cleanup 2007-05-09 18:17:10 +00:00
Howard Chu
28493e554c ITS#4912 fix typo in prev commit 2007-04-05 00:16:17 +00:00