]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
ITS#9534 additional
authorHoward Chu <hyc@openldap.org>
Sat, 24 Apr 2021 14:45:58 +0000 (15:45 +0100)
committerHoward Chu <hyc@openldap.org>
Sat, 24 Apr 2021 14:45:58 +0000 (15:45 +0100)
Partially revert 0b20b92ec1b5d658f80ceb8fe4c4dfeef8f33cc9
Reuse the client conn for delta-sync startup

servers/slapd/syncrepl.c

index 51745097685e3c36d3b26eacbd2bec74e33c82d5..d6b1ab21d5ab9868a343bd46bd765964c1385b64 100644 (file)
@@ -1900,6 +1900,8 @@ done:
        if ( msg ) ldap_msgfree( msg );
 
        if ( rc ) {
+               if ( rc == LDAP_SYNC_REFRESH_REQUIRED && si->si_logstate == SYNCLOG_LOGGING && si->si_ld )
+                       return rc
                /* never reuse existing connection */
                if ( si->si_conn ) {
                        connection_client_stop( si->si_conn );
@@ -2027,7 +2029,6 @@ do_syncrepl(
        if ( !si->si_schemachecking )
                op->o_no_schema_check = 1;
 
-reload:
        /* Establish session, do search */
        if ( !si->si_ld ) {
                si->si_refreshDelete = 0;
@@ -2045,6 +2046,7 @@ reload:
                rc = do_syncrep1( op, si );
        }
 
+reload:
        /* Process results */
        if ( rc == LDAP_SUCCESS ) {
                ldap_get_option( si->si_ld, LDAP_OPT_DESC, &s );
@@ -2066,8 +2068,14 @@ reload:
                op->o_ndn = op->o_bd->be_rootndn;
                rc = do_syncrep2( op, si );
                if ( rc == LDAP_SYNC_REFRESH_REQUIRED ) {
-                       if ( si->si_logstate == SYNCLOG_LOGGING )
+                       if ( si->si_logstate == SYNCLOG_LOGGING ) {
+                               if ( BER_BVISNULL( &si->si_syncCookie.octet_str ))
+                                       slap_compose_sync_cookie( NULL, &si->si_syncCookie.octet_str,
+                                               si->si_syncCookie.ctxcsn, si->si_syncCookie.rid,
+                                               si->si_syncCookie.sid, NULL );
+                               rc = ldap_sync_search( si, op->o_tmpmemctx );
                                goto reload;
+                       }
                        /* give up but schedule an immedite retry */
                        rc = SYNC_PAUSED;
                }