From c607449cd02db9423a8e28257a25983313b200b4 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Tue, 7 Dec 2004 02:20:15 +0000 Subject: [PATCH] Write contextCSN during db_open if it's newer than was previously recorded --- servers/slapd/overlays/syncprov.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/servers/slapd/overlays/syncprov.c b/servers/slapd/overlays/syncprov.c index edceb1bf1a..97d422198f 100644 --- a/servers/slapd/overlays/syncprov.c +++ b/servers/slapd/overlays/syncprov.c @@ -1689,6 +1689,7 @@ syncprov_db_open( Connection conn; char opbuf[OPERATION_BUFFER_SIZE]; + char ctxcsnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE]; Operation *op = (Operation *)opbuf; Entry *e; Attribute *a; @@ -1699,6 +1700,8 @@ syncprov_db_open( op->o_dn = be->be_rootdn; op->o_ndn = be->be_rootndn; + ctxcsnbuf[0] = '\0'; + op->o_bd->bd_info = on->on_info->oi_orig; rc = be_entry_get_rw( op, be->be_nsuffix, NULL, slap_schema.si_ad_contextCSN, 0, &e ); @@ -1712,6 +1715,7 @@ syncprov_db_open( strncpy( si->si_ctxcsnbuf, a->a_nvals[0].bv_val, si->si_ctxcsn.bv_len ); si->si_ctxcsnbuf[si->si_ctxcsn.bv_len] = '\0'; + strcpy( ctxcsnbuf, si->si_ctxcsnbuf ); } be_entry_release_r( op, e ); op->o_bd->bd_info = (BackendInfo *)on; @@ -1726,6 +1730,14 @@ syncprov_db_open( &si->si_ctxcsn, 0 ); } + /* If our ctxcsn is different from what was read from the root + * entry, write the new value out. + */ + if ( strcmp( si->si_ctxcsnbuf, ctxcsnbuf )) { + SlapReply rs = {REP_RESULT}; + syncprov_checkpoint( op, &rs, on ); + } + op->o_bd->bd_info = (BackendInfo *)on; return 0; } -- 2.39.5