From ebecca737942cf000c140a053431bf47662aa8ae Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 9 Apr 2003 17:34:58 +0000 Subject: [PATCH] Eliminate getkey search --- servers/slapd/connection.c | 7 ++++--- servers/slapd/sl_malloc.c | 15 +++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 7975348b22..432a4b43ca 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -888,6 +888,7 @@ connection_operation( void *ctx, void *arg_v ) ber_tag_t oldtag = tag; #endif /* SLAPD_MONITOR */ Connection *conn = op->o_conn; + void *memctx; ldap_pvt_thread_mutex_lock( &num_ops_mutex ); num_ops_initiated++; @@ -915,9 +916,9 @@ connection_operation( void *ctx, void *arg_v ) */ #define SLAB_SIZE 1048576 if ( tag == LDAP_REQ_SEARCH ) { - sl_mem_create( SLAB_SIZE, ctx ); - ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, ctx ); - op->o_tmpmemctx = ctx; + memctx = sl_mem_create( SLAB_SIZE, ctx ); + ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, memctx ); + op->o_tmpmemctx = memctx; op->o_tmpalloc = sl_malloc; op->o_tmpfree = sl_free; } else { diff --git a/servers/slapd/sl_malloc.c b/servers/slapd/sl_malloc.c index fff4270418..3a5d15c399 100644 --- a/servers/slapd/sl_malloc.c +++ b/servers/slapd/sl_malloc.c @@ -44,7 +44,7 @@ sl_mem_init() ber_set_option( NULL, LBER_OPT_MEMORY_FNS, &sl_bmf ); } -void +void * sl_mem_create( ber_len_t size, void *ctx @@ -68,6 +68,7 @@ sl_mem_create( } sh->h_last = sh->h_base; sh->h_end = sh->h_base + size; + return sh; } void * @@ -76,15 +77,13 @@ sl_malloc( void *ctx ) { - struct slab_heap *sh = NULL; + struct slab_heap *sh = ctx; int pad = 2*sizeof(int)-1; ber_len_t *new; /* ber_set_option calls us like this */ if (!ctx) return ber_memalloc_x( size, NULL ); - ldap_pvt_thread_pool_getkey( ctx, sl_mem_init, (void **)&sh, NULL ); - /* round up to doubleword boundary */ size += pad + sizeof( ber_len_t ); size &= ~pad; @@ -122,13 +121,11 @@ sl_calloc( ber_len_t n, ber_len_t size, void *ctx ) void * sl_realloc( void *ptr, ber_len_t size, void *ctx ) { - struct slab_heap *sh = NULL; + struct slab_heap *sh = ctx; int pad = 2*sizeof(int)-1; ber_len_t *p = (ber_len_t *)ptr; ber_len_t *new; - ldap_pvt_thread_pool_getkey( ctx, sl_mem_init, (void **)&sh, NULL ); - if ( ptr == NULL ) return sl_malloc( size, ctx ); if ( ptr < sh->h_base || ptr >= sh->h_end ) { @@ -163,9 +160,7 @@ sl_realloc( void *ptr, ber_len_t size, void *ctx ) void sl_free( void *ptr, void *ctx ) { - struct slab_heap *sh = NULL; - - ldap_pvt_thread_pool_getkey( ctx, sl_mem_init, (void **)&sh, NULL ); + struct slab_heap *sh = ctx; if ( ptr < sh->h_base || ptr >= sh->h_end ) { #ifdef NEW_LOGGING -- 2.39.5