[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: read locks with bdb when using slapacl (ITS#3245)



ando@sys-net.it wrote:

>Full_Name: Pierangelo Masarati
>Version: HEAD
>OS: irrelevant
>URL: ftp://ftp.openldap.org/incoming/
>Submission from: (NULL) (81.74.43.82)
>Submitted by: ando
>
>
>slapacl uses ACL related calls that acquire read-locked entries intended for
>SLAP_SERVER_MODE, but released as SLAP_TOOL_MODE.  This leaves read-locks that 
>lock subsequent use of the database.  A suggested fix is coming.
>  
>
I've just committed a fix to back-bdb/id2entry.c:

diff -u -r1.53 -r1.54
--- id2entry.c  4 Jul 2004 02:56:36 -0000       1.53
+++ id2entry.c  17 Jul 2004 12:45:07 -0000      1.54
@@ -376,15 +376,22 @@
        if( rc != LDAP_SUCCESS ) {
                /* free entry */
                bdb_cache_return_entry_rw(bdb->bi_dbenv, &bdb->bi_cache, 
e, rw, &lock);
+
        } else {
-               *ent = e;
-               /* big drag. we need a place to store a read lock so we can
-                * release it later??
-                */
-               if ( op && !boi ) {
-                       boi = op->o_tmpcalloc(1,sizeof(struct 
bdb_op_info),op->o_tmpmemctx);
-                       boi->boi_lock = lock;
-                       op->o_private = boi;
+               if ( slapMode == SLAP_SERVER_MODE ) {
+                       *ent = e;
+                       /* big drag. we need a place to store a read 
lock so we can
+                        * release it later??
+                        */
+                       if ( op && !boi ) {
+                               boi = op->o_tmpcalloc(1,sizeof(struct 
bdb_op_info),op->o_tmpmemctx);
+                               boi->boi_lock = lock;
+                               op->o_private = boi;
+                       }
+
+               } else {
+                       *ent = entry_dup( e );
+                       bdb_cache_return_entry_rw(bdb->bi_dbenv, 
&bdb->bi_cache, e, rw, &lock);
                }
        }
 
This seems to do the trick; the entry is freed later by the (required) 
subsequent call
to bdb_entry_release() which, in tool mode, takes care of freeing the 
entry regardless
of its e_private field.

Please review.

p.




    SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497