mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-22 23:59:34 -05:00
Added slap_op_init/destroy, cache Operation structures
This commit is contained in:
parent
f14561d59d
commit
fec1c7b54c
2 changed files with 35 additions and 2 deletions
|
|
@ -361,6 +361,7 @@ int main( int argc, char **argv )
|
||||||
|
|
||||||
extops_init();
|
extops_init();
|
||||||
lutil_passwd_init();
|
lutil_passwd_init();
|
||||||
|
slap_op_init();
|
||||||
|
|
||||||
#ifdef SLAPD_MODULES
|
#ifdef SLAPD_MODULES
|
||||||
if ( module_init() != 0 ) {
|
if ( module_init() != 0 ) {
|
||||||
|
|
@ -587,6 +588,8 @@ destroy:
|
||||||
module_kill();
|
module_kill();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
slap_op_destroy();
|
||||||
|
|
||||||
extops_kill();
|
extops_kill();
|
||||||
|
|
||||||
stop:
|
stop:
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,26 @@
|
||||||
#include "slapi.h"
|
#include "slapi.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static ldap_pvt_thread_mutex_t slap_op_mutex;
|
||||||
|
static LDAP_STAILQ_HEAD(s_o, slap_op) slap_free_ops;
|
||||||
|
|
||||||
|
void slap_op_init()
|
||||||
|
{
|
||||||
|
ldap_pvt_thread_mutex_init( &slap_op_mutex );
|
||||||
|
LDAP_STAILQ_INIT(&slap_free_ops);
|
||||||
|
}
|
||||||
|
|
||||||
|
void slap_op_destroy()
|
||||||
|
{
|
||||||
|
Operation *o;
|
||||||
|
|
||||||
|
while ( (o = LDAP_STAILQ_FIRST( &slap_free_ops )) != NULL) {
|
||||||
|
LDAP_STAILQ_REMOVE_HEAD( &slap_free_ops, o_next );
|
||||||
|
LDAP_STAILQ_NEXT(o, o_next) = NULL;
|
||||||
|
ch_free( o );
|
||||||
|
}
|
||||||
|
ldap_pvt_thread_mutex_destroy( &slap_op_mutex );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
slap_op_free( Operation *op )
|
slap_op_free( Operation *op )
|
||||||
|
|
@ -62,7 +82,10 @@ slap_op_free( Operation *op )
|
||||||
}
|
}
|
||||||
#endif /* defined( LDAP_SLAPI ) */
|
#endif /* defined( LDAP_SLAPI ) */
|
||||||
|
|
||||||
free( (char *) op );
|
memset( op, 0, sizeof(Operation) );
|
||||||
|
ldap_pvt_thread_mutex_lock( &slap_op_mutex );
|
||||||
|
LDAP_STAILQ_INSERT_HEAD( &slap_free_ops, op, o_next );
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_op_mutex );
|
||||||
}
|
}
|
||||||
|
|
||||||
Operation *
|
Operation *
|
||||||
|
|
@ -75,6 +98,13 @@ slap_op_alloc(
|
||||||
{
|
{
|
||||||
Operation *op;
|
Operation *op;
|
||||||
|
|
||||||
|
ldap_pvt_thread_mutex_lock( &slap_op_mutex );
|
||||||
|
if (op = LDAP_STAILQ_FIRST( &slap_free_ops )) {
|
||||||
|
LDAP_STAILQ_REMOVE_HEAD( &slap_free_ops, o_next );
|
||||||
|
}
|
||||||
|
ldap_pvt_thread_mutex_unlock( &slap_op_mutex );
|
||||||
|
|
||||||
|
if (!op)
|
||||||
op = (Operation *) ch_calloc( 1, sizeof(Operation) );
|
op = (Operation *) ch_calloc( 1, sizeof(Operation) );
|
||||||
|
|
||||||
op->o_ber = ber;
|
op->o_ber = ber;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue