From: Kurt Spanier Date: Mon, 19 Apr 1999 10:47:03 +0000 (+0000) Subject: Delayed backend lock release to replog entry after successful add(). X-Git-Tag: OPENLDAP_SLAPD_BACK_LDAP~163 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f1e7ffb176feafd3f2ad5859c9e40a942c622c63;p=openldap Delayed backend lock release to replog entry after successful add(). --- diff --git a/servers/slapd/back-bdb2/add.c b/servers/slapd/back-bdb2/add.c index c3a5b69b0c..f4e40709c6 100644 --- a/servers/slapd/back-bdb2/add.c +++ b/servers/slapd/back-bdb2/add.c @@ -11,6 +11,9 @@ #include "back-bdb2.h" #include "proto-back-bdb2.h" +static DB_LOCK lock; + + static int bdb2i_back_add_internal( BackendDB *be, @@ -217,7 +220,7 @@ return_results:; bdb2i_cache_return_entry_w( &li->li_cache, p ); } - if ( 1 || rc ) { + if ( rc ) { /* free entry and writer lock */ bdb2i_cache_return_entry_w( &li->li_cache, e ); } @@ -234,9 +237,8 @@ bdb2_back_add( Entry *e ) { - DB_LOCK lock; struct ldbminfo *li = (struct ldbminfo *) be->be_private; - struct timeval time1, time2; + struct timeval time1; int ret; bdb2i_start_timing( be->bd_info, &time1 ); @@ -248,8 +250,6 @@ bdb2_back_add( } - bdb2i_start_timing( be->bd_info, &time2 ); - /* check, if a new default attribute index will be created, in which case we have to open the index file BEFORE TP */ switch ( slapMode ) { @@ -262,11 +262,22 @@ bdb2_back_add( } ret = bdb2i_back_add_internal( be, conn, op, e ); - bdb2i_stop_timing( be->bd_info, time2, "ADD-INTERN", conn, op ); - (void) bdb2i_leave_backend_w( lock ); + + /* if the operation was successful, we will delay the unlock */ + if ( ret ) + (void) bdb2i_leave_backend_w( lock ); + bdb2i_stop_timing( be->bd_info, time1, "ADD", conn, op ); return( ret ); } +int +bdb2i_release_add_lock( void ) +{ + (void) bdb2i_leave_backend_w( lock ); + return 0; +} + + diff --git a/servers/slapd/back-bdb2/entry.c b/servers/slapd/back-bdb2/entry.c index d5ed790066..4d9f76d95e 100644 --- a/servers/slapd/back-bdb2/entry.c +++ b/servers/slapd/back-bdb2/entry.c @@ -19,12 +19,11 @@ bdb2_back_entry_release_rw( int rw ) { -#if 0 struct ldbminfo *li = (struct ldbminfo *) be->be_private; /* free entry and reader or writer lock */ bdb2i_cache_return_entry_rw( &li->li_cache, e, rw ); -#endif + bdb2i_release_add_lock(); return 0; } diff --git a/servers/slapd/back-bdb2/proto-back-bdb2.h b/servers/slapd/back-bdb2/proto-back-bdb2.h index 04b787fe8c..159757450d 100644 --- a/servers/slapd/back-bdb2/proto-back-bdb2.h +++ b/servers/slapd/back-bdb2/proto-back-bdb2.h @@ -9,6 +9,11 @@ LDAP_BEGIN_DECL +/* + * add.c + */ +int bdb2i_release_add_lock LDAP_P(()); + /* * alias.c */