Commit 2be22ecd authored by Quanah Gibson-Mount's avatar Quanah Gibson-Mount
Browse files

Merge remote-tracking branch 'origin/master' into OPENLDAP_REL_ENG_2_5

parents 3cc3d702 ebb4b82f
#! /bin/sh
# From configure.in Id: d9579fd63cb1e1b81292655b40f8ab8509120b85 .
# From configure.in Id: 152f0e7f02bbc65c2945514b3847006fb1eaf288 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69.
#
......@@ -702,7 +702,6 @@ BUILD_RELAY
BUILD_PASSWD
BUILD_NULL
BUILD_NDB
BUILD_MONITOR
BUILD_ASYNCMETA
BUILD_META
BUILD_MDB
......@@ -854,7 +853,6 @@ enable_ldap
enable_mdb
enable_meta
enable_asyncmeta
enable_monitor
enable_ndb
enable_null
enable_passwd
......@@ -1556,7 +1554,6 @@ SLAPD Backend Options:
--enable-mdb enable mdb database backend no|yes|mod [yes]
--enable-meta enable metadirectory backend no|yes|mod [no]
--enable-asyncmeta enable asynchronous metadirectory backend no|yes|mod [no]
--enable-monitor enable monitor backend no|yes|mod [yes]
--enable-ndb enable MySQL NDB Cluster backend no|yes|mod [no]
--enable-null enable null backend no|yes|mod [no]
--enable-passwd enable passwd backend no|yes|mod [no]
......@@ -3467,7 +3464,6 @@ Backends="dnssrv \
mdb \
meta \
asyncmeta \
monitor \
ndb \
null \
passwd \
......@@ -3607,27 +3603,6 @@ else
fi
 
# end --enable-asyncmeta
# OpenLDAP --enable-monitor
# Check whether --enable-monitor was given.
if test "${enable_monitor+set}" = set; then :
enableval=$enable_monitor;
ol_arg=invalid
for ol_val in no yes mod ; do
if test "$enableval" = "$ol_val" ; then
ol_arg="$ol_val"
fi
done
if test "$ol_arg" = "invalid" ; then
as_fn_error $? "bad value $enableval for --enable-monitor" "$LINENO" 5
fi
ol_enable_monitor="$ol_arg"
else
ol_enable_monitor=${ol_enable_backends:-yes}
fi
# end --enable-monitor
# OpenLDAP --enable-ndb
 
# Check whether --enable-ndb was given.
......@@ -4475,7 +4450,6 @@ BUILD_LDAP=no
BUILD_MDB=no
BUILD_META=no
BUILD_ASYNCMETA=no
BUILD_MONITOR=no
BUILD_NDB=no
BUILD_NULL=no
BUILD_PASSWD=no
......@@ -4515,7 +4489,7 @@ SLAPD_DYNAMIC_OVERLAYS=
SLAPD_MODULES_LDFLAGS=
SLAPD_MODULES_CPPFLAGS=
 
SLAPD_STATIC_BACKENDS=back-ldif
SLAPD_STATIC_BACKENDS="back-ldif back-monitor"
SLAPD_DYNAMIC_BACKENDS=
 
SLAPD_PERL_LDFLAGS=
......@@ -24542,23 +24516,6 @@ $as_echo "#define SLAPD_MOD_STATIC 1" >>confdefs.h
$as_echo "#define SLAPD_MOD_DYNAMIC 2" >>confdefs.h
 
 
if test "$ol_enable_monitor" != no ; then
BUILD_SLAPD=yes
BUILD_MONITOR=$ol_enable_monitor
if test "$ol_enable_monitor" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-monitor"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-monitor"
MFLAG=SLAPD_MOD_STATIC
fi
cat >>confdefs.h <<_ACEOF
#define SLAPD_MONITOR $MFLAG
_ACEOF
fi
if test "$ol_enable_dnssrv" != no ; then
BUILD_SLAPD=yes
BUILD_DNSSRV=$ol_enable_dnssrv
......@@ -25228,7 +25185,6 @@ fi
 
 
 
 
 
# Check whether --with-xxinstall was given.
......
......@@ -294,7 +294,6 @@ Backends="dnssrv \
mdb \
meta \
asyncmeta \
monitor \
ndb \
null \
passwd \
......@@ -319,8 +318,6 @@ OL_ARG_ENABLE(meta, [AS_HELP_STRING([--enable-meta], [enable metadirectory backe
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(asyncmeta, [AS_HELP_STRING([--enable-asyncmeta], [enable asynchronous metadirectory backend])],
no, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(monitor, [AS_HELP_STRING([--enable-monitor], [enable monitor backend])],
yes, [no yes mod], ol_enable_backends)dnl
OL_ARG_ENABLE(ndb, [AS_HELP_STRING([--enable-ndb], [enable MySQL NDB Cluster backend])],
no, [no yes mod])dnl
OL_ARG_ENABLE(null, [AS_HELP_STRING([--enable-null], [enable null backend])],
......@@ -522,7 +519,6 @@ BUILD_LDAP=no
BUILD_MDB=no
BUILD_META=no
BUILD_ASYNCMETA=no
BUILD_MONITOR=no
BUILD_NDB=no
BUILD_NULL=no
BUILD_PASSWD=no
......@@ -562,7 +558,7 @@ SLAPD_DYNAMIC_OVERLAYS=
SLAPD_MODULES_LDFLAGS=
SLAPD_MODULES_CPPFLAGS=
SLAPD_STATIC_BACKENDS=back-ldif
SLAPD_STATIC_BACKENDS="back-ldif back-monitor"
SLAPD_DYNAMIC_BACKENDS=
SLAPD_PERL_LDFLAGS=
......@@ -2490,20 +2486,6 @@ fi
AC_DEFINE(SLAPD_MOD_STATIC,1,[statically linked module])
AC_DEFINE(SLAPD_MOD_DYNAMIC,2,[dynamically linked module])
dnl back-monitor goes first (well, after back-config)
if test "$ol_enable_monitor" != no ; then
BUILD_SLAPD=yes
BUILD_MONITOR=$ol_enable_monitor
if test "$ol_enable_monitor" = mod ; then
SLAPD_DYNAMIC_BACKENDS="$SLAPD_DYNAMIC_BACKENDS back-monitor"
MFLAG=SLAPD_MOD_DYNAMIC
else
SLAPD_STATIC_BACKENDS="$SLAPD_STATIC_BACKENDS back-monitor"
MFLAG=SLAPD_MOD_STATIC
fi
AC_DEFINE_UNQUOTED(SLAPD_MONITOR,$MFLAG,[define to support cn=Monitor backend])
fi
if test "$ol_enable_dnssrv" != no ; then
BUILD_SLAPD=yes
BUILD_DNSSRV=$ol_enable_dnssrv
......@@ -2968,7 +2950,6 @@ dnl backends
AC_SUBST(BUILD_MDB)
AC_SUBST(BUILD_META)
AC_SUBST(BUILD_ASYNCMETA)
AC_SUBST(BUILD_MONITOR)
AC_SUBST(BUILD_NDB)
AC_SUBST(BUILD_NULL)
AC_SUBST(BUILD_PASSWD)
......
......@@ -937,7 +937,6 @@ The following example is for a self-contained push-based replication solution:
> modulepath /usr/local/libexec/openldap
> moduleload back_mdb.la
> moduleload syncprov.la
> moduleload back_monitor.la
> moduleload back_ldap.la
>
> pidfile /usr/local/var/slapd.pid
......@@ -1021,7 +1020,6 @@ A replica configuration for this type of setup could be:
> modulepath /usr/local/libexec/openldap
> moduleload back_mdb.la
> moduleload syncprov.la
> moduleload back_monitor.la
> moduleload back_ldap.la
>
> pidfile /usr/local/var/slapd.pid
......
......@@ -23,11 +23,7 @@
# include <sys/errno.h>
#endif
#ifndef HAVE_SYS_ERRLIST
/* no sys_errlist */
# define sys_nerr 0
# define sys_errlist ((char **)0)
#elif defined( DECL_SYS_ERRLIST )
#if defined( HAVE_SYS_ERRLIST ) && defined( DECL_SYS_ERRLIST )
/* have sys_errlist but need declaration */
LDAP_LIBC_V(int) sys_nerr;
LDAP_LIBC_V(char) *sys_errlist[];
......
......@@ -936,9 +936,6 @@
/* statically linked module */
#undef SLAPD_MOD_STATIC
/* define to support cn=Monitor backend */
#undef SLAPD_MONITOR
/* define to support NDB backend */
#undef SLAPD_NDB
......
......@@ -844,8 +844,7 @@ ldap_back_monitor_initialize( void )
/* set to 0 when successfully initialized; otherwise, remember failure */
static int ldap_back_monitor_initialized_failure = 1;
/* register schema here; if compiled as dynamic object,
* must be loaded __after__ back_monitor.la */
/* register schema here */
if ( ldap_back_monitor_initialized++ ) {
return ldap_back_monitor_initialized_failure;
......@@ -962,7 +961,7 @@ ldap_back_monitor_db_open( BackendDB *be )
static int warning = 0;
if ( warning++ == 0 ) {
Debug( LDAP_DEBUG_ANY, "ldap_back_monitor_db_open: "
Debug( LDAP_DEBUG_CONFIG, "ldap_back_monitor_db_open: "
"monitoring disabled; "
"configure monitor database to enable\n" );
}
......
......@@ -449,19 +449,35 @@ do_del:
a2 = attr_find( e->e_attrs, ap->a_desc );
if ( a2 ) {
/* need to detect which values were deleted */
int i, j;
int i, j, k;
/* let add know there were deletes */
if ( a2->a_flags & SLAP_ATTR_IXADD )
a2->a_flags |= SLAP_ATTR_IXDEL;
vals = op->o_tmpalloc( (ap->a_numvals + 1) *
sizeof(struct berval), op->o_tmpmemctx );
j = 0;
for ( i=0; i < ap->a_numvals; i++ ) {
rc = attr_valfind( a2, SLAP_MR_ASSERTED_VALUE_NORMALIZED_MATCH,
&ap->a_nvals[i], NULL, op->o_tmpmemctx );
/* Save deleted values */
if ( rc == LDAP_NO_SUCH_ATTRIBUTE )
vals[j++] = ap->a_nvals[i];
for ( i=k=0; i < ap->a_numvals; i++ ) {
char found = 0;
BerValue* current = &ap->a_nvals[i];
int k2 = k;
for (k2 = k ; k2 < a2->a_numvals; k2 ++) {
int match = -1, rc;
const char *text;
rc = ordered_value_match( &match, a2->a_desc,
ap->a_desc->ad_type->sat_equality, 0,
&a2->a_nvals[k2], current, &text );
if ( rc == LDAP_SUCCESS && match == 0 ) {
found = 1;
break;
}
}
if (!found) {
vals[j++] = *current;
} else {
k = k2 + 1;
}
}
BER_BVZERO(vals+j);
} else {
......
......@@ -427,7 +427,7 @@ mdb_monitor_db_open( BackendDB *be )
static int warning = 0;
if ( warning++ == 0 ) {
Debug( LDAP_DEBUG_ANY, LDAP_XSTRING(mdb_monitor_db_open)
Debug( LDAP_DEBUG_CONFIG, LDAP_XSTRING(mdb_monitor_db_open)
": monitoring disabled; "
"configure monitor database to enable\n" );
}
......
......@@ -28,10 +28,10 @@ LDAP_INCDIR= ../../../include
LDAP_LIBDIR= ../../../libraries
BUILD_OPT = "--enable-monitor"
BUILD_MOD = @BUILD_MONITOR@
BUILD_MOD = yes
mod_DEFS = -DSLAPD_IMPORT
MOD_DEFS = $(@BUILD_MONITOR@_DEFS)
MOD_DEFS = $(yes_DEFS)
shared_LDAP_LIBS = $(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA)
NT_LINK_LIBS = -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS)
......
......@@ -72,6 +72,7 @@ typedef struct monitor_entry_t {
/* NOTE: flags with 0xF0000000U mask are reserved for subsystem internals */
struct monitor_callback_t *mp_cb; /* callback sequence */
void *mp_private;
} monitor_entry_t;
struct entry_limbo_t; /* in init.c */
......
......@@ -346,6 +346,7 @@ monitor_subsys_database_init_one(
mp->mp_info = ms;
mp->mp_flags = ms->mss_flags
| MONITOR_F_SUB;
mp->mp_private = be;
if ( monitor_cache_add( mi, e ) ) {
Debug( LDAP_DEBUG_ANY,
......@@ -444,31 +445,13 @@ monitor_back_register_database_and_overlay(
mp = ( monitor_entry_t * )e_database->e_private;
for ( i = -1, ep = &mp->mp_children; *ep; i++ ) {
Attribute *a;
a = attr_find( (*ep)->e_attrs, slap_schema.si_ad_namingContexts );
if ( a ) {
int j, k;
/* FIXME: RFC 4512 defines namingContexts without an
* equality matching rule, making comparisons
* like this one tricky. We use a_vals and
* be_suffix instead for now.
*/
for ( j = 0; !BER_BVISNULL( &a->a_vals[ j ] ); j++ ) {
for ( k = 0; !BER_BVISNULL( &be->be_suffix[ k ] ); k++ ) {
if ( dn_match( &a->a_vals[ j ],
&be->be_suffix[ k ] ) ) {
rc = 0;
goto done;
}
}
}
}
mp = ( monitor_entry_t * )(*ep)->e_private;
assert( mp != NULL );
if ( mp->mp_private == be->bd_self ) {
rc = 0;
goto done;
}
ep = &mp->mp_next;
}
......
......@@ -2562,11 +2562,3 @@ monitor_back_db_destroy(
return 0;
}
#if SLAPD_MONITOR == SLAPD_MOD_DYNAMIC
/* conditionally define the init_module() function */
SLAP_BACKEND_INIT_MODULE( monitor )
#endif /* SLAPD_MONITOR == SLAPD_MOD_DYNAMIC */
......@@ -119,7 +119,6 @@ int backend_init(void)
/* HACK: need schema defined in deterministic order */
syncrepl_monitor_init();
if ( nBackendInfo > 0) {
return 0;
}
......
......@@ -306,12 +306,7 @@ static Connection* connection_get( ber_socket_t s )
assert( c->c_conn_state != SLAP_C_INVALID );
assert( c->c_sd != AC_SOCKET_INVALID );
#ifndef SLAPD_MONITOR
if ( global_idletimeout > 0 )
#endif /* ! SLAPD_MONITOR */
{
c->c_activitytime = slap_get_time();
}
c->c_activitytime = slap_get_time();
}
return c;
......@@ -463,12 +458,7 @@ Connection * connection_init(
/* set to zero until bind, implies LDAP_VERSION3 */
c->c_protocol = 0;
#ifndef SLAPD_MONITOR
if ( global_idletimeout > 0 )
#endif /* ! SLAPD_MONITOR */
{
c->c_activitytime = c->c_starttime = slap_get_time();
}
c->c_activitytime = c->c_starttime = slap_get_time();
#ifdef LDAP_CONNECTIONLESS
c->c_is_udp = 0;
......@@ -960,7 +950,6 @@ void connection_done( Connection *c )
* calls the appropriate stub to handle it.
*/
#ifdef SLAPD_MONITOR
/* FIXME: returns 0 in case of failure */
#define INCR_OP_INITIATED(index) \
do { \
......@@ -975,15 +964,6 @@ void connection_done( Connection *c )
ldap_pvt_mp_add_ulong(op->o_counters->sc_ops_completed_[(index)], 1); \
ldap_pvt_thread_mutex_unlock( &op->o_counters->sc_mutex ); \
} while (0)
#else /* !SLAPD_MONITOR */
#define INCR_OP_INITIATED(index) do { } while (0)
#define INCR_OP_COMPLETED(index) \
do { \
ldap_pvt_thread_mutex_lock( &op->o_counters->sc_mutex ); \
ldap_pvt_mp_add_ulong(op->o_counters->sc_ops_completed, 1); \
ldap_pvt_thread_mutex_unlock( &op->o_counters->sc_mutex ); \
} while (0)
#endif /* !SLAPD_MONITOR */
/*
* NOTE: keep in sync with enum in slapd.h
......@@ -1023,12 +1003,10 @@ conn_counter_destroy( void *key, void *data )
ldap_pvt_mp_add( slap_counters.sc_refs, sc->sc_refs );
ldap_pvt_mp_add( slap_counters.sc_ops_initiated, sc->sc_ops_initiated );
ldap_pvt_mp_add( slap_counters.sc_ops_completed, sc->sc_ops_completed );
#ifdef SLAPD_MONITOR
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
ldap_pvt_mp_add( slap_counters.sc_ops_initiated_[ i ], sc->sc_ops_initiated_[ i ] );
ldap_pvt_mp_add( slap_counters.sc_ops_initiated_[ i ], sc->sc_ops_completed_[ i ] );
}
#endif /* SLAPD_MONITOR */
slap_counters_destroy( sc );
ber_memfree_x( data, NULL );
break;
......
......@@ -107,7 +107,7 @@ static int emfile;
static volatile int waking;
#define WAKE_LISTENER(l,w) do { \
if (w) { \
tcp_write( SLAP_FD2SOCK(wake_sds[l][1]), "0", 1 ); \
(void)!tcp_write( SLAP_FD2SOCK(wake_sds[l][1]), "0", 1 ); \
} \
} while (0)
......@@ -2137,7 +2137,7 @@ slap_sockaddrstr( Sockaddr *sa, struct berval *addrbuf )
strcpy(addrbuf->bv_val, "IP=");
if ( IN6_IS_ADDR_V4MAPPED(&sa->sa_in6_addr.sin6_addr) ) {
#if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
addr = inet_ntop( AF_INET,
addr = (char *)inet_ntop( AF_INET,
((struct in_addr *)&sa->sa_in6_addr.sin6_addr.s6_addr[12]),
addrbuf->bv_val+3, addrbuf->bv_len-3 );
#else /* ! HAVE_GETADDRINFO || ! HAVE_INET_NTOP */
......@@ -2154,7 +2154,7 @@ slap_sockaddrstr( Sockaddr *sa, struct berval *addrbuf )
(unsigned) ntohs( sa->sa_in6_addr.sin6_port ) ) + len + 3;
}
} else {
addr = inet_ntop( AF_INET6,
addr = (char *)inet_ntop( AF_INET6,
&sa->sa_in6_addr.sin6_addr,
addrbuf->bv_val+4, addrbuf->bv_len-4 );
if ( !addr ) addr = SLAP_STRING_UNKNOWN;
......@@ -2173,7 +2173,7 @@ slap_sockaddrstr( Sockaddr *sa, struct berval *addrbuf )
case AF_INET:
strcpy(addrbuf->bv_val, "IP=");
#if defined( HAVE_GETADDRINFO ) && defined( HAVE_INET_NTOP )
addr = inet_ntop( AF_INET, &sa->sa_in_addr.sin_addr,
addr = (char *)inet_ntop( AF_INET, &sa->sa_in_addr.sin_addr,
addrbuf->bv_val+3, addrbuf->bv_len-3 );
#else /* ! HAVE_GETADDRINFO || ! HAVE_INET_NTOP */
addr = inet_ntoa( sa->sa_in_addr.sin_addr );
......@@ -3130,7 +3130,7 @@ loop:
if ( fd == wake_sds[tid][0] ) {
char c[BUFSIZ];
waking = 0;
tcp_read( SLAP_FD2SOCK(wake_sds[tid][0]), c, sizeof(c) );
(void)!tcp_read( SLAP_FD2SOCK(wake_sds[tid][0]), c, sizeof(c) );
continue;
}
......
......@@ -297,12 +297,10 @@ void slap_counters_init( slap_counters_t *sc )
ldap_pvt_mp_init( sc->sc_ops_initiated );
ldap_pvt_mp_init( sc->sc_ops_completed );
#ifdef SLAPD_MONITOR
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
ldap_pvt_mp_init( sc->sc_ops_initiated_[ i ] );
ldap_pvt_mp_init( sc->sc_ops_completed_[ i ] );
}
#endif /* SLAPD_MONITOR */
}
void slap_counters_destroy( slap_counters_t *sc )
......@@ -318,11 +316,9 @@ void slap_counters_destroy( slap_counters_t *sc )
ldap_pvt_mp_clear( sc->sc_ops_initiated );
ldap_pvt_mp_clear( sc->sc_ops_completed );
#ifdef SLAPD_MONITOR
for ( i = 0; i < SLAP_OP_LAST; i++ ) {
ldap_pvt_mp_clear( sc->sc_ops_initiated_[ i ] );
ldap_pvt_mp_clear( sc->sc_ops_completed_[ i ] );
}
#endif /* SLAPD_MONITOR */
}
......@@ -5554,7 +5554,7 @@ pcache_monitor_db_open( BackendDB *be )
static int warning = 0;
if ( warning++ == 0 ) {
Debug( LDAP_DEBUG_ANY, "pcache_monitor_db_open: "
Debug( LDAP_DEBUG_CONFIG, "pcache_monitor_db_open: "
"monitoring disabled; "
"configure monitor database to enable\n" );
}
......
......@@ -2551,10 +2551,8 @@ typedef struct slap_counters_t {
ldap_pvt_mp_t sc_ops_completed;
ldap_pvt_mp_t sc_ops_initiated;
#ifdef SLAPD_MONITOR
ldap_pvt_mp_t sc_ops_completed_[SLAP_OP_LAST];
ldap_pvt_mp_t sc_ops_initiated_[SLAP_OP_LAST];
#endif /* SLAPD_MONITOR */
} slap_counters_t;
/*
......
......@@ -1005,68 +1005,68 @@ do_syncrep1(
} else
{
/* We've just started up, or the remote server hasn't sent us
* any meaningful state.
*/
if ( !si->si_syncCookie.ctxcsn ) {
int i;
/* We've just started up, or the remote server hasn't sent us
* any meaningful state.
*/
if ( !si->si_syncCookie.ctxcsn ) {
int i;
LDAP_STAILQ_FOREACH( sc, &slap_sync_cookie, sc_next ) {
if ( si->si_rid == sc->rid ) {
cmdline_cookie_found = 1;
break;
LDAP_STAILQ_FOREACH( sc, &slap_sync_cookie, sc_next ) {
if ( si->si_rid == sc->rid ) {
cmdline_cookie_found = 1;
break;
}
}
}
if ( cmdline_cookie_found ) {
/* cookie is supplied in the command line */
if ( cmdline_cookie_found ) {
/* cookie is supplied in the command line */
LDAP_STAILQ_REMOVE( &slap_sync_cookie, sc, sync_cookie, sc_next );
LDAP_STAILQ_REMOVE( &slap_sync_cookie, sc, sync_cookie, sc_next );
slap_sync_cookie_free( &si->si_syncCookie, 0 );
si->si_syncCookie.octet_str = sc->octet_str;
ch_free( sc );
/* ctxcsn wasn't parsed yet, do it now */
slap_parse_sync_cookie( &si->si_syncCookie, NULL );
} else {
ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
if ( !si->si_cookieState->cs_num ) {
/* get contextCSN shadow replica from database */
BerVarray csn = NULL;
void *ctx = op->o_tmpmemctx;
op->o_req_ndn = si->si_contextdn;
op->o_req_dn = op->o_req_ndn;
/* try to read stored contextCSN */
op->o_tmpmemctx = NULL;
backend_attribute( op, NULL, &op->o_req_ndn,
slap_schema.si_ad_contextCSN, &csn, ACL_READ );
op->o_tmpmemctx = ctx;
if ( csn ) {
si->si_cookieState->cs_vals = csn;
for (i=0; !BER_BVISNULL( &csn[i] ); i++);
si->si_cookieState->cs_num = i;
si->si_cookieState->cs_sids = slap_parse_csn_sids( csn, i, NULL );
slap_sort_csn_sids( csn, si->si_cookieState->cs_sids, i, NULL );
slap_sync_cookie_free( &si->si_syncCookie, 0 );
si->si_syncCookie.octet_str = sc->octet_str;
ch_free( sc );
/* ctxcsn wasn't parsed yet, do it now */
slap_parse_sync_cookie( &si->si_syncCookie, NULL );
} else {
ldap_pvt_thread_mutex_lock( &si->si_cookieState->cs_mutex );
if ( !si->si_cookieState->cs_num ) {
/* get contextCSN shadow replica from database */
BerVarray csn = NULL;
void *ctx = op->o_tmpmemctx;
op->o_req_ndn = si->si_contextdn;
op->o_req_dn = op->o_req_ndn;
/* try to read stored contextCSN */
op->o_tmpmemctx = NULL;
backend_attribute( op, NULL, &op->o_req_ndn,
slap_schema.si_ad_contextCSN, &csn, ACL_READ );
op->o_tmpmemctx = ctx;
if ( csn ) {
si->si_cookieState->cs_vals = csn;
for (i=0; !BER_BVISNULL( &csn[i] ); i++);
si->si_cookieState->cs_num = i;
si->si_cookieState->cs_sids = slap_parse_csn_sids( csn, i, NULL );
slap_sort_csn_sids( csn, si->si_cookieState->cs_sids, i, NULL );
}
}
}
if ( si->si_cookieState->cs_num ) {
ber_bvarray_free( si->si_syncCookie.ctxcsn );
if ( ber_bvarray_dup_x( &si->si_syncCookie.ctxcsn,
si->si_cookieState->cs_vals, NULL )) {
rc = LDAP_NO_MEMORY;
ldap_pvt_thread_mutex_unlock( &si->si_cookieState->cs_mutex );