]> git.sur5r.net Git - openldap/commitdiff
Fix mod locking
authorHoward Chu <hyc@openldap.org>
Mon, 6 Dec 2004 20:32:53 +0000 (20:32 +0000)
committerHoward Chu <hyc@openldap.org>
Mon, 6 Dec 2004 20:32:53 +0000 (20:32 +0000)
servers/slapd/overlays/syncprov.c

index 37abf73a73277992424145535378bfa2a9620eee..edceb1bf1a07903d3473f0f35b3d4b94a50321bb 100644 (file)
@@ -102,7 +102,7 @@ typedef struct syncprov_info_t {
        Avlnode *si_mods;       /* entries being modified */
        ldap_pvt_thread_mutex_t si_csn_mutex;
        ldap_pvt_thread_mutex_t si_ops_mutex;
-       ldap_pvt_thread_rdwr_t  si_mods_rwlock;
+       ldap_pvt_thread_mutex_t si_mods_mutex;
        char            si_ctxcsnbuf[LDAP_LUTIL_CSNSTR_BUFSIZE];
 } syncprov_info_t;
 
@@ -971,9 +971,9 @@ syncprov_op_cleanup( Operation *op, SlapReply *rs )
 
        /* Remove op from lock table */
        mtdummy.mt_op = op;
-       ldap_pvt_thread_rdwr_rlock( &si->si_mods_rwlock );
+       ldap_pvt_thread_mutex_lock( &si->si_mods_mutex );
        mt = avl_find( si->si_mods, &mtdummy, sp_avl_cmp );
-       ldap_pvt_thread_rdwr_runlock( &si->si_mods_rwlock );
+       ldap_pvt_thread_mutex_unlock( &si->si_mods_mutex );
        if ( mt ) {
                modinst *mi = mt->mt_mods;
 
@@ -984,9 +984,9 @@ syncprov_op_cleanup( Operation *op, SlapReply *rs )
                        mt->mt_op = mt->mt_mods->mi_op;
                        ldap_pvt_thread_mutex_unlock( &mt->mt_mutex );
                } else {
-                       ldap_pvt_thread_rdwr_wlock( &si->si_mods_rwlock );
+                       ldap_pvt_thread_mutex_lock( &si->si_mods_mutex );
                        avl_delete( &si->si_mods, mt, sp_avl_cmp );
-                       ldap_pvt_thread_rdwr_wunlock( &si->si_mods_rwlock );
+                       ldap_pvt_thread_mutex_unlock( &si->si_mods_mutex );
                        ldap_pvt_thread_mutex_unlock( &mt->mt_mutex );
                        ldap_pvt_thread_mutex_destroy( &mt->mt_mutex );
                        ch_free( mt );
@@ -1207,11 +1207,11 @@ syncprov_op_mod( Operation *op, SlapReply *rs )
 
                /* See if we're already modifying this entry... */
                mtdummy.mt_op = op;
-               ldap_pvt_thread_rdwr_wlock( &si->si_mods_rwlock );
+               ldap_pvt_thread_mutex_lock( &si->si_mods_mutex );
                mt = avl_find( si->si_mods, &mtdummy, sp_avl_cmp );
                if ( mt ) {
                        ldap_pvt_thread_mutex_lock( &mt->mt_mutex );
-                       ldap_pvt_thread_rdwr_wunlock( &si->si_mods_rwlock );
+                       ldap_pvt_thread_mutex_unlock( &si->si_mods_mutex );
                        mt->mt_tail->mi_next = mi;
                        mt->mt_tail = mi;
                        /* wait for this op to get to head of list */
@@ -1220,6 +1220,7 @@ syncprov_op_mod( Operation *op, SlapReply *rs )
                                ldap_pvt_thread_yield();
                                ldap_pvt_thread_mutex_lock( &mt->mt_mutex );
                        }
+                       ldap_pvt_thread_mutex_unlock( &mt->mt_mutex );
                } else {
                        /* Record that we're modifying this entry now */
                        mt = ch_malloc( sizeof(modtarget) );
@@ -1228,7 +1229,7 @@ syncprov_op_mod( Operation *op, SlapReply *rs )
                        mt->mt_op = mi->mi_op;
                        ldap_pvt_thread_mutex_init( &mt->mt_mutex );
                        avl_insert( &si->si_mods, mt, sp_avl_cmp, avl_dup_error );
-                       ldap_pvt_thread_rdwr_wunlock( &si->si_mods_rwlock );
+                       ldap_pvt_thread_mutex_unlock( &si->si_mods_mutex );
                }
 
                if ( op->o_tag != LDAP_REQ_ADD )
@@ -1773,7 +1774,7 @@ syncprov_db_init(
        on->on_bi.bi_private = si;
        ldap_pvt_thread_mutex_init( &si->si_csn_mutex );
        ldap_pvt_thread_mutex_init( &si->si_ops_mutex );
-       ldap_pvt_thread_rdwr_init( &si->si_mods_rwlock );
+       ldap_pvt_thread_mutex_init( &si->si_mods_mutex );
        si->si_ctxcsn.bv_val = si->si_ctxcsnbuf;
 
        csn_anlist[0].an_desc = slap_schema.si_ad_entryCSN;
@@ -1794,7 +1795,7 @@ syncprov_db_destroy(
        syncprov_info_t *si = (syncprov_info_t *)on->on_bi.bi_private;
 
        if ( si ) {
-               ldap_pvt_thread_rdwr_destroy( &si->si_mods_rwlock );
+               ldap_pvt_thread_mutex_destroy( &si->si_mods_mutex );
                ldap_pvt_thread_mutex_destroy( &si->si_ops_mutex );
                ldap_pvt_thread_mutex_destroy( &si->si_csn_mutex );
                ch_free( si );