]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/connection.c
filter_candidate tweaks, search_stack tweaks
[openldap] / servers / slapd / connection.c
index b0a6378fbf8c50dd25dede4ba07bce8f6bd09f3d..436a76c5d2cb33948a84b3fceb1107b70aa20d9a 100644 (file)
@@ -888,6 +888,8 @@ connection_operation( void *ctx, void *arg_v )
        ber_tag_t oldtag = tag;
 #endif /* SLAPD_MONITOR */
        Connection *conn = op->o_conn;
+       void *memctx;
+       ber_len_t memsiz;
 
        ldap_pvt_thread_mutex_lock( &num_ops_mutex );
        num_ops_initiated++;
@@ -910,19 +912,21 @@ connection_operation( void *ctx, void *arg_v )
                goto operations_error;
        }
 
-       /* For all operations besides Add, we can use thread-local
-        * storage for most mallocs.
+       /* We can use Thread-Local storage for most mallocs. We can
+        * also use TL for ber parsing, but not on Add or Modify.
         */
-       if ( tag == LDAP_REQ_SEARCH ) {
-               sl_mem_create( ber_len( op->o_ber ) * 16, ctx );
-               ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, ctx );
-               op->o_tmpmemctx = ctx;
-               op->o_tmpalloc = sl_malloc;
-               op->o_tmpfree = sl_free;
-       } else {
-               op->o_tmpmemctx = NULL;
-               op->o_tmpalloc = (BER_MEMALLOC_FN *)ch_malloc;
-               op->o_tmpfree = (BER_MEMFREE_FN *)ch_free;
+#define        SLAB_SIZE       1048576
+#if 0
+       memsiz = ber_len( op->o_ber ) * 64;
+       if ( SLAB_SIZE > memsiz ) memsiz = SLAB_SIZE;
+#endif
+       memsiz = SLAB_SIZE;
+
+       memctx = sl_mem_create( memsiz, ctx );
+       op->o_tmpmemctx = memctx;
+       op->o_tmpmfuncs = &sl_mfuncs;
+       if ( tag != LDAP_REQ_ADD && tag != LDAP_REQ_MODIFY ) {
+               ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, memctx );
        }
 
        switch ( tag ) {
@@ -1072,6 +1076,7 @@ operations_error:
 
 co_op_free:
 
+       ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, NULL );
        slap_op_free( op );
 
 no_co_op_free: