e = (Entry *) ch_calloc( 1, sizeof(Entry) );
- rs->sr_err = dnPrettyNormal( NULL, &dn, &e->e_name, &e->e_nname, op->o_tmpmemctx );
+ rs->sr_err = dnPrettyNormal( NULL, &dn, &op->o_req_dn, &op->o_req_ndn, op->o_tmpmemctx );
if( rs->sr_err != LDAP_SUCCESS ) {
#ifdef NEW_LOGGING
goto done;
}
+ ber_dupbv( &e->e_name, &op->o_req_dn );
+ ber_dupbv( &e->e_nname, &op->o_req_ndn );
+
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ARGS,
"do_add: conn %d dn (%s)\n", op->o_connid, e->e_dn, 0 );
Debug( LDAP_DEBUG_ARGS, "do_add: dn (%s)\n", e->e_dn, 0, 0 );
#endif
- op->o_req_dn = e->e_name;
- op->o_req_ndn = e->e_nname;
-
/* get the attrs */
for ( tag = ber_first_element( ber, &len, &last ); tag != LBER_DEFAULT;
tag = ber_next_element( ber, &len, last ) )
size_t textlen = sizeof textbuf;
rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
- textbuf, textlen, op->o_tmpmemctx );
+ textbuf, textlen, NULL );
if( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
if( e != NULL ) {
entry_free( e );
}
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
return rs->sr_err;
}
else
db_rw = DB_LOCK_READ;
+#if 0
lockobj.data = e->e_nname.bv_val;
lockobj.size = e->e_nname.bv_len;
+#else
+ lockobj.data = &e->e_private;
+ lockobj.size = sizeof(e->e_private);
+#endif
rc = LOCK_GET(env, locker, flags | DB_LOCK_NOWAIT,
&lockobj, db_rw, lock);
if (rc) {
/* Build target dn and make sure target entry doesn't exist already. */
if (!new_dn.bv_val) build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn );
- if (!new_ndn.bv_val) dnNormalize2( NULL, &new_dn, &new_ndn, op->o_tmpmemctx );
+ if (!new_ndn.bv_val) {
+ struct berval bv = {0, NULL};
+ dnNormalize2( NULL, &new_dn, &bv, op->o_tmpmemctx );
+ ber_dupbv( &new_ndn, &bv );
+ }
#ifdef NEW_LOGGING
LDAP_LOG ( OPERATION, RESULTS,
/* LDAP v2 supporting correct attribute handling. */
if ( new_rdn != NULL ) {
- ldap_rdnfree( new_rdn );
+ ldap_rdnfree_x( new_rdn, op->o_tmpmemctx );
}
if ( old_rdn != NULL ) {
- ldap_rdnfree( old_rdn );
+ ldap_rdnfree_x( old_rdn, op->o_tmpmemctx );
}
if( mod != NULL ) {
Modifications *tmp;
}
if( ndn.bv_val != NULL ) {
- free( ndn.bv_val );
+ op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx );
}
if( ltid != NULL ) {
/* Build target dn and make sure target entry doesn't exist already. */
build_new_dn( &new_dn, new_parent_dn, &op->oq_modrdn.rs_newrdn );
- dnNormalize2( NULL, &new_dn, &new_ndn, op->o_tmpmemctx );
+ dnNormalize2( NULL, &new_dn, &new_ndn, NULL );
#ifdef NEW_LOGGING
LDAP_LOG( BACK_LDBM, DETAIL1, "ldbm_back_modrdn: new ndn=%s\n",
}
if( ndn.bv_val != NULL ) {
- free( ndn.bv_val );
+ op->o_tmpfree( ndn.bv_val, op->o_tmpmemctx );
}
return rc;
#endif /* defined( LDAP_SLAPI ) */
cleanup:
- free( op->o_req_dn.bv_val );
- free( op->o_req_ndn.bv_val );
- if ( ava.aa_value.bv_val ) free( ava.aa_value.bv_val );
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
+ if ( ava.aa_value.bv_val ) op->o_tmpfree( ava.aa_value.bv_val, op->o_tmpmemctx );
return rs->sr_err;
}
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.
*/
#define SLAB_SIZE 1048576
- memsiz = ber_len( op->o_ber ) * 32;
+#if 0
+ memsiz = ber_len( op->o_ber ) * 64;
if ( SLAB_SIZE > memsiz ) memsiz = SLAB_SIZE;
+#endif
+ memsiz = SLAB_SIZE;
- if ( tag == LDAP_REQ_SEARCH || tag == LDAP_REQ_BIND ) {
- memctx = sl_mem_create( memsiz, ctx );
+ 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 );
- op->o_tmpmemctx = memctx;
- op->o_tmpmfuncs = &sl_mfuncs;
- } else {
- op->o_tmpmemctx = NULL;
- op->o_tmpmfuncs = &ch_mfuncs;
}
switch ( tag ) {
#endif /* defined( LDAP_SLAPI ) */
cleanup:
- free( op->o_req_dn.bv_val );
- free( op->o_req_ndn.bv_val );
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
return rs->sr_err;
}
size_t textlen = sizeof textbuf;
rs->sr_err = slap_mods_check( modlist, update, &rs->sr_text,
- textbuf, textlen, op->o_tmpmemctx );
+ textbuf, textlen, NULL );
if( rs->sr_err != LDAP_SUCCESS ) {
send_ldap_result( op, rs );
#endif /* defined( LDAP_SLAPI ) */
cleanup:
- free( op->o_req_dn.bv_val );
- free( op->o_req_ndn.bv_val );
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
if ( modlist != NULL ) slap_mods_free( modlist );
#if defined( LDAP_SLAPI )
if ( modv != NULL ) slapi_x_free_ldapmods( modv );
#endif /* defined( LDAP_SLAPI ) */
cleanup:
- free( op->o_req_dn.bv_val );
- free( op->o_req_ndn.bv_val );
+ op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
- free( op->orr_newrdn.bv_val );
- free( op->orr_nnewrdn.bv_val );
+ op->o_tmpfree( op->orr_newrdn.bv_val, op->o_tmpmemctx );
+ op->o_tmpfree( op->orr_nnewrdn.bv_val, op->o_tmpmemctx );
- if ( pnewSuperior.bv_val ) free( pnewSuperior.bv_val );
- if ( nnewSuperior.bv_val ) free( nnewSuperior.bv_val );
+ if ( pnewSuperior.bv_val ) op->o_tmpfree( pnewSuperior.bv_val, op->o_tmpmemctx );
+ if ( nnewSuperior.bv_val ) op->o_tmpfree( nnewSuperior.bv_val, op->o_tmpmemctx );
return rs->sr_err;
}
ber = op->o_res_ber;
else
#endif
- ber_init_w_nullc( ber, LBER_USE_DER );
+ {
+ ber_init_w_nullc( ber, LBER_USE_DER );
+ ber_set_option( ber, LBER_OPT_BER_MEMCTX, op->o_tmpmemctx );
+ }
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY,
{
char berbuf[LBER_ELEMENT_SIZEOF];
BerElement *ber = (BerElement *)berbuf;
- int rc;
+ int rc = 0;
int bytes;
+ void *mark;
AttributeDescription *ad_ref = slap_schema.si_ad_ref;
AttributeDescription *ad_entry = slap_schema.si_ad_entry;
return op->o_callback->sc_response( op, rs );
}
+ mark = sl_mark( op->o_tmpmemctx );
+
#ifdef NEW_LOGGING
LDAP_LOG( OPERATION, ENTRY,
"send_search_reference: conn %lu dn=\"%s\"\n",
"send_search_reference: access to entry not allowed\n",
0, 0, 0 );
#endif
-
- return( 1 );
+ rc = 1;
+ goto rel;
}
if ( rs->sr_entry && ! access_allowed( op, rs->sr_entry,
"to reference not allowed\n",
0, 0, 0 );
#endif
-
- return( 1 );
+ rc = 1;
+ goto rel;
}
#ifdef LDAP_CONTROL_X_DOMAIN_SCOPE
"send_search_reference: domainScope control in (%s)\n",
rs->sr_entry->e_dn, 0, 0 );
#endif
-
- return( 0 );
+ rc = 0;
+ goto rel;
}
#endif
"send_search_reference: null ref in (%s)\n",
rs->sr_entry ? rs->sr_entry->e_dn : "(null)", 0, 0 );
#endif
-
- return( 1 );
+ rc = 1;
+ goto rel;
}
if( op->o_protocol < LDAP_VERSION3 ) {
if( value_add( &rs->sr_v2ref, rs->sr_ref ) )
return LDAP_OTHER;
}
- return 0;
+ rc = 0;
+ goto rel;
}
#ifdef LDAP_CONNECTIONLESS
ber = op->o_res_ber;
else
#endif
- ber_init_w_nullc( ber, LBER_USE_DER );
+ {
+ ber_init_w_nullc( ber, LBER_USE_DER );
+ ber_set_option( ber, LBER_OPT_BER_MEMCTX, op->o_tmpmemctx );
+ }
rc = ber_printf( ber, "{it{W}" /*"}"*/ , op->o_msgid,
LDAP_RES_SEARCH_REFERENCE, rs->sr_ref );
#endif
ber_free_buf( ber );
send_ldap_error( op, rs, LDAP_OTHER, "encode DN error" );
- return -1;
+ goto rel;
}
#ifdef LDAP_CONNECTIONLESS
Debug( LDAP_DEBUG_TRACE, "<= send_search_reference\n", 0, 0, 0 );
#endif
- return 0;
+rel:
+ sl_release( mark, op->o_tmpmemctx );
+ return rc;
}
int
}
}
+ rc = LDAP_NO_SUCH_ATTRIBUTE;
for ( i = 0; vals[i].bv_val != NULL; i++ ) {
int match;
const char *text;
&vals[i], nval.bv_val == NULL ? val : &nval, &text );
if( rc == LDAP_SUCCESS && match == 0 ) {
- free( nval.bv_val );
- return LDAP_SUCCESS;
+ break;
}
}
- ber_memfree_x( nval.bv_val, ctx );
- return LDAP_NO_SUCH_ATTRIBUTE;
+ sl_free( nval.bv_val, ctx );
+ return rc;
}