]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/overlays/syncprov.c
ITS#3682, dup entry and free the DB's copy before sending it
[openldap] / servers / slapd / overlays / syncprov.c
index 973ec678d95b437f1e3d564b5b354a31fddf4045..f184dd2815c7e57e2159013a32ba751573fb7380 100644 (file)
@@ -841,6 +841,14 @@ syncprov_sendresp( Operation *op, opcookie *opc, syncops *so, Entry **e, int mod
        op->o_tmpfree( rs.sr_ctrls[0], op->o_tmpmemctx );
        op->o_private = sop.o_private;
        rs.sr_ctrls = NULL;
+       /* Check queue again here; if we were hanging in a send and eventually
+        * recovered, there may be more to send now.
+        */
+       if ( rs.sr_err == LDAP_SUCCESS && queue && so->s_res ) {
+               ldap_pvt_thread_mutex_lock( &so->s_mutex );
+               rs.sr_err = syncprov_qplay( &sop, on, so );
+               ldap_pvt_thread_mutex_unlock( &so->s_mutex );
+       }
        return rs.sr_err;
 }
 
@@ -968,6 +976,12 @@ syncprov_matchops( Operation *op, opcookie *opc, int saveit )
        if ( op->o_tag != LDAP_REQ_ADD ) {
                op->o_bd->bd_info = (BackendInfo *)on->on_info;
                rc = be_entry_get_rw( op, fc.fdn, NULL, NULL, 0, &e );
+               /* If we're sending responses now, make a copy and unlock the DB */
+               if ( e && !saveit ) {
+                       Entry *e2 = entry_dup( e );
+                       be_entry_release_rw( op, e, 0 );
+                       e = e2;
+               }
                op->o_bd->bd_info = (BackendInfo *)on;
                if ( rc ) return;
        } else {