From 99e22a4366469c2675f65acf28a0d8f8fbd38f14 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Sun, 23 Jun 2013 19:13:52 -0700 Subject: [PATCH] ITS#7628 fix back-mdb txn refcount If multiple ops used the same opinfo the refcount wasn't being decremented --- servers/slapd/back-mdb/add.c | 2 ++ servers/slapd/back-mdb/bind.c | 2 ++ servers/slapd/back-mdb/compare.c | 2 ++ servers/slapd/back-mdb/delete.c | 2 ++ servers/slapd/back-mdb/id2entry.c | 3 ++- servers/slapd/back-mdb/modify.c | 2 ++ servers/slapd/back-mdb/modrdn.c | 2 ++ servers/slapd/back-mdb/operational.c | 2 ++ servers/slapd/back-mdb/referral.c | 2 ++ servers/slapd/back-mdb/search.c | 2 ++ 10 files changed, 20 insertions(+), 1 deletion(-) diff --git a/servers/slapd/back-mdb/add.c b/servers/slapd/back-mdb/add.c index 289eb321a2..1b70597149 100644 --- a/servers/slapd/back-mdb/add.c +++ b/servers/slapd/back-mdb/add.c @@ -438,6 +438,8 @@ return_results: if ( opinfo.moi_oe.oe_key ) { LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next ); } + } else { + moi->moi_ref--; } if( success == LDAP_SUCCESS ) { diff --git a/servers/slapd/back-mdb/bind.c b/servers/slapd/back-mdb/bind.c index 0cd716e71f..1563723294 100644 --- a/servers/slapd/back-mdb/bind.c +++ b/servers/slapd/back-mdb/bind.c @@ -138,6 +138,8 @@ done: if ( moi == &opinfo ) { mdb_txn_reset( moi->moi_txn ); LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next ); + } else { + moi->moi_ref--; } /* free entry and reader lock */ if( e != NULL ) { diff --git a/servers/slapd/back-mdb/compare.c b/servers/slapd/back-mdb/compare.c index 3ea188fef2..81f583cf7e 100644 --- a/servers/slapd/back-mdb/compare.c +++ b/servers/slapd/back-mdb/compare.c @@ -130,6 +130,8 @@ done: if ( moi == &opinfo ) { mdb_txn_reset( moi->moi_txn ); LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next ); + } else { + moi->moi_ref--; } /* free entry */ if ( e != NULL ) { diff --git a/servers/slapd/back-mdb/delete.c b/servers/slapd/back-mdb/delete.c index 1735fee799..ac857395b2 100644 --- a/servers/slapd/back-mdb/delete.c +++ b/servers/slapd/back-mdb/delete.c @@ -457,6 +457,8 @@ return_results: if ( opinfo.moi_oe.oe_key ) { LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next ); } + } else { + moi->moi_ref--; } send_ldap_result( op, rs ); diff --git a/servers/slapd/back-mdb/id2entry.c b/servers/slapd/back-mdb/id2entry.c index 84de09d125..a86a25ce7e 100644 --- a/servers/slapd/back-mdb/id2entry.c +++ b/servers/slapd/back-mdb/id2entry.c @@ -505,7 +505,8 @@ mdb_opinfo_get( Operation *op, struct mdb_info *mdb, int rdonly, mdb_op_info **m moi->moi_ref = 0; } if ( renew ) { - mdb_txn_renew( moi->moi_txn ); + rc = mdb_txn_renew( moi->moi_txn ); + assert(!rc); } moi->moi_ref++; if ( *moip != moi ) diff --git a/servers/slapd/back-mdb/modify.c b/servers/slapd/back-mdb/modify.c index 1ea664f4fe..1a81e820a0 100644 --- a/servers/slapd/back-mdb/modify.c +++ b/servers/slapd/back-mdb/modify.c @@ -671,6 +671,8 @@ done: if ( opinfo.moi_oe.oe_key ) { LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next ); } + } else { + moi->moi_ref--; } if( e != NULL ) { diff --git a/servers/slapd/back-mdb/modrdn.c b/servers/slapd/back-mdb/modrdn.c index f70457bdaf..2aa545d242 100644 --- a/servers/slapd/back-mdb/modrdn.c +++ b/servers/slapd/back-mdb/modrdn.c @@ -656,6 +656,8 @@ done: if ( opinfo.moi_oe.oe_key ) { LDAP_SLIST_REMOVE( &op->o_extra, &opinfo.moi_oe, OpExtra, oe_next ); } + } else { + moi->moi_ref--; } if( preread_ctrl != NULL && (*preread_ctrl) != NULL ) { diff --git a/servers/slapd/back-mdb/operational.c b/servers/slapd/back-mdb/operational.c index 4937984b7f..398df1271d 100644 --- a/servers/slapd/back-mdb/operational.c +++ b/servers/slapd/back-mdb/operational.c @@ -76,6 +76,8 @@ done:; if ( moi == &opinfo ) { mdb_txn_reset( moi->moi_txn ); LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next ); + } else { + moi->moi_ref--; } return rc; } diff --git a/servers/slapd/back-mdb/referral.c b/servers/slapd/back-mdb/referral.c index c253f2ee0c..1325c442e7 100644 --- a/servers/slapd/back-mdb/referral.c +++ b/servers/slapd/back-mdb/referral.c @@ -142,6 +142,8 @@ done: if ( moi == &opinfo ) { mdb_txn_reset( moi->moi_txn ); LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next ); + } else { + moi->moi_ref--; } if ( e ) mdb_entry_return( op, e ); diff --git a/servers/slapd/back-mdb/search.c b/servers/slapd/back-mdb/search.c index 286d5e734e..5cc0d28c00 100644 --- a/servers/slapd/back-mdb/search.c +++ b/servers/slapd/back-mdb/search.c @@ -1058,6 +1058,8 @@ done: if ( moi == &opinfo ) { mdb_txn_reset( moi->moi_txn ); LDAP_SLIST_REMOVE( &op->o_extra, &moi->moi_oe, OpExtra, oe_next ); + } else { + moi->moi_ref--; } if( rs->sr_v2ref ) { ber_bvarray_free( rs->sr_v2ref );