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++;
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 ) {
co_op_free:
+ ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, NULL );
slap_op_free( op );
no_co_op_free: