/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * 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
int
add_replica_info(
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++ );
be->be_replica[ i ]
= ch_calloc( sizeof( struct slap_replica_info ), 1 );
- be->be_replica[ i ]->ri_host = ch_strdup( host );
+ be->be_replica[ i ]->ri_uri = 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;
void
replog( Operation *op )
{
- Modifications *ml = NULL;
- Attribute *a = NULL;
FILE *fp, *lfp;
int i;
/* undef NO_LOG_WHEN_NO_REPLICAS */
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 && frontendDB->be_replogfile == NULL ) {
+ replogfile = op->o_bd->be_replogfile ? op->o_bd->be_replogfile :
+ frontendDB->be_replogfile;
+ if ( !replogfile ) {
return;
}
- ldap_pvt_thread_mutex_lock( &SLAPD_GLOBAL(replog_mutex) );
- if ( (fp = lock_fopen( op->o_bd->be_replogfile ? op->o_bd->be_replogfile :
- frontendDB->be_replogfile, "a", &lfp )) == NULL ) {
- ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) );
+ ldap_pvt_thread_mutex_lock( &replog_mutex );
+ if ( (fp = lock_fopen( replogfile, "a", &lfp )) == NULL ) {
+ ldap_pvt_thread_mutex_unlock( &replog_mutex );
return;
}
/* if no replicas matched, drop the log
* (should we log it anyway?) */
lock_fclose( fp, lfp );
- ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) );
+ ldap_pvt_thread_mutex_unlock( &replog_mutex );
return;
}
}
lock_fclose( fp, lfp );
- ldap_pvt_thread_mutex_unlock( &SLAPD_GLOBAL(replog_mutex) );
+ ldap_pvt_thread_mutex_unlock( &replog_mutex );
}
static void
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;