X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Frepl.c;h=73b3c8ca96c03f60ced1da115e4c2c8efef14d1c;hb=53d41587adf505c0421b5bf47516ebd0e66818c7;hp=f8ac323a8443fbfe353312c30bb181384500803b;hpb=7e87f547160f78690b4fe2a6bdf7f67505de8ee4;p=openldap diff --git a/servers/slapd/repl.c b/servers/slapd/repl.c index f8ac323a84..73b3c8ca96 100644 --- a/servers/slapd/repl.c +++ b/servers/slapd/repl.c @@ -2,7 +2,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2004 The OpenLDAP Foundation. + * Copyright 1998-2005 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,14 +41,14 @@ int add_replica_info( - Backend *be, - const char *host -) + Backend *be, + const char *uri, + const char *host ) { int i = 0; - assert( be ); - assert( host ); + assert( be != NULL ); + assert( host != NULL ); if ( be->be_replica != NULL ) { for ( ; be->be_replica[ i ] != NULL; i++ ); @@ -59,7 +59,8 @@ add_replica_info( be->be_replica[ i ] = ch_calloc( sizeof( struct slap_replica_info ), 1 ); - be->be_replica[ i ]->ri_host = ch_strdup( host ); + ber_str2bv( uri, 0, 0, &be->be_replica[ i ]->ri_bindconf.sb_uri ); + be->be_replica[ i ]->ri_host = host; be->be_replica[ i ]->ri_nsuffix = NULL; be->be_replica[ i ]->ri_attrs = NULL; be->be_replica[ i + 1 ] = NULL; @@ -67,6 +68,42 @@ add_replica_info( return( i ); } +int +destroy_replica_info( + Backend *be ) +{ + int i = 0; + + assert( be != NULL ); + + if ( be->be_replica == NULL ) { + return 0; + } + + for ( ; be->be_replica[ i ] != NULL; i++ ) { + ber_bvarray_free( be->be_replica[ i ]->ri_nsuffix ); + + if ( be->be_replica[ i ]->ri_attrs ) { + AttributeName *an = be->be_replica[ i ]->ri_attrs; + int j; + + for ( j = 0; !BER_BVISNULL( &an[ j ].an_name ); j++ ) + { + ch_free( an[ j ].an_name.bv_val ); + } + ch_free( an ); + } + + bindconf_free( &be->be_replica[ i ]->ri_bindconf ); + + ch_free( be->be_replica[ i ] ); + } + + ch_free( be->be_replica ); + + return 0; +} + int add_replica_suffix( Backend *be, @@ -124,8 +161,6 @@ replog1( struct slap_replica_info *ri, Operation *op, FILE *fp, long now); void replog( Operation *op ) { - Modifications *ml = NULL; - Attribute *a = NULL; FILE *fp, *lfp; int i; /* undef NO_LOG_WHEN_NO_REPLICAS */ @@ -133,15 +168,17 @@ replog( Operation *op ) int count = 0; #endif int subsets = 0; - long now = slap_get_time(); + long now = slap_get_time(); + char *replogfile; - if ( op->o_bd->be_replogfile == NULL && replogfile == NULL ) { + replogfile = op->o_bd->be_replogfile ? op->o_bd->be_replogfile : + frontendDB->be_replogfile; + if ( !replogfile ) { return; } ldap_pvt_thread_mutex_lock( &replog_mutex ); - if ( (fp = lock_fopen( op->o_bd->be_replogfile ? op->o_bd->be_replogfile : - replogfile, "a", &lfp )) == NULL ) { + if ( (fp = lock_fopen( replogfile, "a", &lfp )) == NULL ) { ldap_pvt_thread_mutex_unlock( &replog_mutex ); return; } @@ -274,7 +311,7 @@ replog1( case LDAP_REQ_MODIFY: for ( ml = op->orm_modlist; ml != NULL; ml = ml->sml_next ) { - char *did, *type = ml->sml_desc->ad_cname.bv_val; + char *did = NULL, *type = ml->sml_desc->ad_cname.bv_val; switch ( ml->sml_op ) { case LDAP_MOD_ADD: did = "add"; break;