From 11e23f6903fc2f1dea3b8df3cf40933616580fb6 Mon Sep 17 00:00:00 2001 From: Jong Hyuk Choi Date: Wed, 22 Oct 2003 06:28:34 +0000 Subject: [PATCH] syncrepl_entry() return code fix (returns 1 when e needs to be freed) --- servers/slapd/syncrepl.c | 43 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 733e2e2e4e..248ff32658 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -870,6 +870,7 @@ syncrepl_entry( SlapReply rs = {REP_RESULT}; int rc = LDAP_SUCCESS; + int ret = LDAP_SUCCESS; if ( refresh && ( syncstate == LDAP_SYNC_PRESENT || syncstate == LDAP_SYNC_ADD )) @@ -927,10 +928,6 @@ syncrepl_entry( rc = be->be_delete( op, &rs ); } - if ( si->si_syncUUID_ndn ) { - ber_bvfree( si->si_syncUUID_ndn ); - } - switch ( syncstate ) { case LDAP_SYNC_ADD: case LDAP_SYNC_MODIFY: @@ -967,13 +964,15 @@ syncrepl_entry( rc, 0, 0 ); #endif } - return 1; + ret = 1; + goto done; } else if ( rc == LDAP_REFERRAL || rc == LDAP_NO_SUCH_OBJECT ) { syncrepl_add_glue( si, ld, op, e, modlist, syncstate, syncUUID, syncCookie); si->si_e = NULL; - return 0; + ret = 0; + goto done; } else { #ifdef NEW_LOGGING LDAP_LOG( OPERATION, ERR, @@ -985,12 +984,14 @@ syncrepl_entry( rc, 0, 0 ); #endif si->si_e = NULL; - return 1; + ret = 1; + goto done; } } else { si->si_e = NULL; be_entry_release_w( op, e ); - return 0; + ret = 0; + goto done; } } else { #ifdef NEW_LOGGING @@ -1001,18 +1002,22 @@ syncrepl_entry( "syncrepl_entry : be_search failed (%d)\n", rc, 0, 0 ); #endif si->si_e = NULL; - return 1; + ret = 1; + goto done; } case LDAP_SYNC_DELETE : if ( si->si_sync_mode == LDAP_SYNC_LOG_MODE ) { - op->o_req_dn = *si->si_syncUUID_ndn; - op->o_req_ndn = *si->si_syncUUID_ndn; - op->o_tag = LDAP_REQ_DELETE; - rc = be->be_delete( op, &rs ); + if ( si->si_syncUUID_ndn ) { + op->o_req_dn = *si->si_syncUUID_ndn; + op->o_req_ndn = *si->si_syncUUID_ndn; + op->o_tag = LDAP_REQ_DELETE; + rc = be->be_delete( op, &rs ); + } } /* Already deleted otherwise */ - return 0; + ret = 1; + goto done; default : #ifdef NEW_LOGGING @@ -1022,8 +1027,16 @@ syncrepl_entry( Debug( LDAP_DEBUG_ANY, "syncrepl_entry : unknown syncstate\n", 0, 0, 0 ); #endif - return 1; + ret = 1; + goto done; + } + +done : + + if ( si->si_syncUUID_ndn ) { + ber_bvfree( si->si_syncUUID_ndn ); } + return ret; } static void -- 2.39.5