From: Howard Chu Date: Thu, 5 Mar 2009 21:59:05 +0000 (+0000) Subject: Must use txns everywhere, otherwise it will deadlock X-Git-Tag: ACLCHECK_0~739 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e3e7a22b5d7c6410ab54c31038fc153dadc8ca66;p=openldap Must use txns everywhere, otherwise it will deadlock --- diff --git a/servers/slapd/back-bdb/operational.c b/servers/slapd/back-bdb/operational.c index 86a475cc03..4d71ce7001 100644 --- a/servers/slapd/back-bdb/operational.c +++ b/servers/slapd/back-bdb/operational.c @@ -34,6 +34,10 @@ bdb_hasSubordinates( Entry *e, int *hasSubordinates ) { + struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private; + struct bdb_op_info *opinfo; + OpExtra *oex; + DB_TXN *rtxn; int rc; assert( e != NULL ); @@ -47,12 +51,25 @@ bdb_hasSubordinates( return LDAP_OTHER; } + /* Check for a txn in a parent op, otherwise use reader txn */ + LDAP_SLIST_FOREACH( oex, &op->o_extra, oe_next ) { + if ( oex->oe_key == bdb ) + break; + } + opinfo = (struct bdb_op_info *) oex; + if ( opinfo && opinfo->boi_txn ) { + rtxn = opinfo->boi_txn; + } else { + rc = bdb_reader_get(op, bdb->bi_dbenv, &rtxn); + if ( rc ) return LDAP_OTHER; + } + retry: /* FIXME: we can no longer assume the entry's e_private * field is correctly populated; so we need to reacquire * it with reader lock */ - rc = bdb_cache_children( op, NULL, e ); - + rc = bdb_cache_children( op, rtxn, e ); + switch( rc ) { case DB_LOCK_DEADLOCK: case DB_LOCK_NOTGRANTED: