]> git.sur5r.net Git - openldap/commitdiff
Write contextCSN during db_open if it's newer than was previously recorded
authorHoward Chu <hyc@openldap.org>
Tue, 7 Dec 2004 02:20:15 +0000 (02:20 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 7 Dec 2004 02:20:15 +0000 (02:20 +0000)
servers/slapd/overlays/syncprov.c

index edceb1bf1a07903d3473f0f35b3d4b94a50321bb..97d422198f4187efca76813dbef5db8ee5520f17 100644 (file)
@@ -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;
 }