Commit cb921d23 authored by Howard Chu's avatar Howard Chu
Browse files

Merge branch 'memleak26' into 'OPENLDAP_REL_ENG_2_6'

Fix various replication memleaks

See merge request !539
parents dc52e69a c9692a35
Pipeline #4420 passed with stage
in 33 minutes and 21 seconds
......@@ -2373,6 +2373,8 @@ accesslog_db_destroy(
ch_free( li->li_sids );
if ( li->li_mincsn )
ber_bvarray_free( li->li_mincsn );
if ( li->li_db_suffix.bv_val )
ch_free( li->li_db_suffix.bv_val );
ldap_pvt_thread_mutex_destroy( &li->li_log_mutex );
ldap_pvt_thread_mutex_destroy( &li->li_op_rmutex );
free( li );
......
......@@ -3151,6 +3151,8 @@ syncprov_op_search( Operation *op, SlapReply *rs )
*/
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex );
if ( slapd_shutdown ) {
aband:
ch_free( sop->s_base.bv_val );
ch_free( sop );
return SLAPD_ABANDON;
}
......@@ -3160,8 +3162,7 @@ syncprov_op_search( Operation *op, SlapReply *rs )
}
if ( op->o_abandon ) {
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex );
ch_free( sop );
return SLAPD_ABANDON;
goto aband;
}
ldap_pvt_thread_mutex_init( &sop->s_mutex );
sop->s_next = si->si_ops;
......@@ -3290,6 +3291,7 @@ bailout:
sp = &(*sp)->s_next;
*sp = sop->s_next;
ldap_pvt_thread_mutex_unlock( &si->si_ops_mutex );
ch_free( sop->s_base.bv_val );
ch_free( sop );
}
rs->sr_ctrls = NULL;
......@@ -4125,6 +4127,8 @@ syncprov_db_destroy(
ber_bvarray_free( si->si_ctxcsn );
if ( si->si_sids )
ch_free( si->si_sids );
if ( si->si_logbase.bv_val )
ch_free( si->si_logbase.bv_val );
ldap_pvt_thread_mutex_destroy( &si->si_resp_mutex );
ldap_pvt_thread_mutex_destroy( &si->si_mods_mutex );
ldap_pvt_thread_mutex_destroy( &si->si_ops_mutex );
......
......@@ -3115,10 +3115,8 @@ syncrepl_message_to_op(
ch_free( bvals );
goto done;
}
ber_dupbv( &op->o_req_dn, &dn );
ber_dupbv( &op->o_req_ndn, &ndn );
slap_sl_free( ndn.bv_val, op->o_tmpmemctx );
slap_sl_free( dn.bv_val, op->o_tmpmemctx );
op->o_req_dn = dn;
op->o_req_ndn = ndn;
freeReqDn = 1;
} else if ( !ber_bvstrcasecmp( &bv, &ls->ls_req ) ) {
int i = verb_to_mask( bvals[0].bv_val, modops );
......@@ -3228,9 +3226,8 @@ syncrepl_message_to_op(
if ( op->o_tag == LDAP_REQ_ADD ) {
Entry *e = entry_alloc();
op->ora_e = e;
op->ora_e->e_name = op->o_req_dn;
op->ora_e->e_nname = op->o_req_ndn;
freeReqDn = 0;
ber_dupbv( &op->ora_e->e_name, &op->o_req_dn );
ber_dupbv( &op->ora_e->e_nname, &op->o_req_ndn );
rc = slap_mods2entry( modlist, &op->ora_e, 1, 0, &text, txtbuf, textlen);
if( rc != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "syncrepl_message_to_op: %s "
......@@ -3374,8 +3371,8 @@ done:
op->o_tmpfree( op->orr_nnewDN.bv_val, op->o_tmpmemctx );
}
if ( freeReqDn ) {
ch_free( op->o_req_ndn.bv_val );
ch_free( op->o_req_dn.bv_val );
op->o_tmpfree( op->o_req_ndn.bv_val, op->o_tmpmemctx );
op->o_tmpfree( op->o_req_dn.bv_val, op->o_tmpmemctx );
}
ber_free( ber, 0 );
return rc;
......
......@@ -140,12 +140,13 @@ usage( char *name, char opt )
"[-x | -Y <SASL mech>] "
"[-i <interval>] "
"[-s <sids>] "
"[-c <contextDN>] "
"[-b <baseDN> ] URI[...]\n",
name );
exit( EXIT_FAILURE );
}
struct berval base;
struct berval base, cbase;
int interval = 10;
int numservers;
server *servers;
......@@ -511,9 +512,9 @@ setup_server( struct tester_conn_args *config, server *sv )
}
ldap_msgfree( res );
if ( base.bv_val ) {
if ( cbase.bv_val ) {
char *attr2[] = { at_contextCSN.bv_val, NULL };
rc = ldap_search_ext_s( ld, base.bv_val, LDAP_SCOPE_BASE, "(objectClass=*)",
rc = ldap_search_ext_s( ld, cbase.bv_val, LDAP_SCOPE_BASE, "(objectClass=*)",
attr2, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &res );
switch(rc) {
case LDAP_SUCCESS:
......@@ -574,11 +575,17 @@ main( int argc, char **argv )
config = tester_init( "slapd-watcher", TESTER_TESTER );
config->authmethod = LDAP_AUTH_SIMPLE;
while ( ( i = getopt( argc, argv, "D:O:R:U:X:Y:b:d:i:s:w:x" ) ) != EOF )
while ( ( i = getopt( argc, argv, "D:O:R:U:X:Y:b:c:d:i:s:w:x" ) ) != EOF )
{
switch ( i ) {
case 'b': /* base DN for contextCSN lookups */
case 'b': /* base DN for DB entrycount lookups */
ber_str2bv( optarg, 0, 0, &base );
if ( !cbase.bv_val )
cbase = base;
break;
case 'c': /* base DN for contextCSN lookups */
ber_str2bv( optarg, 0, 0, &cbase );
break;
case 'i':
......@@ -690,7 +697,7 @@ server_down1:
}
if (( servers[i].flags & HAS_BASE ) && !msg2[i] ) {
char *attrs[2] = { at_contextCSN.bv_val };
rc = ldap_search_ext( ld, base.bv_val,
rc = ldap_search_ext( ld, cbase.bv_val,
LDAP_SCOPE_BASE, "(objectClass=*)",
attrs, 0, NULL, NULL, NULL, LDAP_NO_LIMIT, &msg2[i] );
if ( rc != LDAP_SUCCESS ) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment