]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
Fix memory leaks from ITS#6310 (logged as ITS#6387)
[openldap] / servers / slapd / syncrepl.c
index 4933933935cc9cea4fd97f3c51fdcdf6307be4d8..7a4e6d41181d164ad29428aab4713889f17dd8c2 100644 (file)
@@ -665,6 +665,11 @@ do_syncrep1(
                        si->si_syncCookie.ctxcsn, si->si_syncCookie.rid,
                        si->si_syncCookie.sid );
        } else {
+               /* ITS#6367: recreate the cookie so it has our SID, not our peer's */
+               ch_free( si->si_syncCookie.octet_str.bv_val );
+               slap_compose_sync_cookie( NULL, &si->si_syncCookie.octet_str,
+                       si->si_syncCookie.ctxcsn, si->si_syncCookie.rid,
+                       si->si_syncCookie.sid );
                /* Look for contextCSN from syncprov overlay. */
                check_syncprov( op, si );
        }
@@ -852,6 +857,7 @@ do_syncrep2(
                                        slap_parse_sync_cookie( &syncCookie, NULL );
                                        if ( syncCookie.ctxcsn ) {
                                                int i, sid = slap_parse_csn_sid( syncCookie.ctxcsn );
+                                               check_syncprov( op, si );
                                                for ( i =0; i<si->si_cookieState->cs_num; i++ ) {
                                                        if ( si->si_cookieState->cs_sids[i] == sid && 
                                                                ber_bvcmp( syncCookie.ctxcsn, &si->si_cookieState->cs_vals[i] ) <= 0 ) {
@@ -3713,7 +3719,7 @@ syncinfo_free( syncinfo_t *sie, int free_all )
                if ( sie->si_logbase.bv_val ) {
                        ch_free( sie->si_logbase.bv_val );
                }
-               if ( SLAP_SYNC_SUBENTRY( sie->si_be )) {
+               if ( sie->si_be && SLAP_SYNC_SUBENTRY( sie->si_be )) {
                        ch_free( sie->si_contextdn.bv_val );
                }
                if ( sie->si_attrs ) {
@@ -3925,6 +3931,12 @@ parse_syncrepl_retry(
                        }
                }
        }
+       if ( j < 1 || si->si_retrynum_init[j-1] != RETRYNUM_FOREVER ) {
+               Debug( LDAP_DEBUG_CONFIG,
+                       "%s: syncrepl will eventually stop retrying; the \"retry\" parameter should end with a '+'.\n",
+                       c->log, 0, 0 );
+       }
+
        si->si_retrynum_init[j] = RETRYNUM_TAIL;
        si->si_retrynum[j] = RETRYNUM_TAIL;
        si->si_retryinterval[j] = 0;