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.
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.
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().
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.
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.
- 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.
(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).
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.
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.
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.