From 62aa401bd74b3f98312de5232463ec644012292f Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Tue, 13 Apr 1999 06:08:28 +0000 Subject: [PATCH] Add struct backend_info->bi_entry_release_rw and related functions. Move cache_return_entry_w() out of ldbm_back_add when the add is successful. This change breaks back-bdb2, it needs equvalent changes of those in back-ldbm. --- servers/slapd/add.c | 1 + servers/slapd/back-ldbm/Makefile.in | 4 ++-- servers/slapd/back-ldbm/add.c | 6 ++++-- servers/slapd/back-ldbm/init.c | 1 + servers/slapd/back-ldbm/proto-back-ldbm.h | 5 +++++ servers/slapd/backend.c | 15 +++++++++++++++ servers/slapd/proto-slap.h | 4 ++++ servers/slapd/slap.h | 2 ++ 8 files changed, 34 insertions(+), 4 deletions(-) diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 16eed3a63c..5e195c726f 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -127,6 +127,7 @@ do_add( Connection *conn, Operation *op ) } if ( (*be->be_add)( be, conn, op, e ) == 0 ) { replog( be, LDAP_REQ_ADD, e->e_dn, e, 0 ); + be_entry_release_w( be, e ); } } else { diff --git a/servers/slapd/back-ldbm/Makefile.in b/servers/slapd/back-ldbm/Makefile.in index 985149e9d9..2aa1e6a8e0 100644 --- a/servers/slapd/back-ldbm/Makefile.in +++ b/servers/slapd/back-ldbm/Makefile.in @@ -1,9 +1,9 @@ XSRCS = version.c -SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c id2entry.c \ +SRCS = idl.c add.c search.c cache.c dbcache.c dn2id.c entry.c id2entry.c \ index.c id2children.c nextid.c abandon.c compare.c group.c \ modify.c modrdn.c delete.c init.c config.c bind.c attr.c \ filterindex.c unbind.c kerberos.c close.c alias.c -OBJS = idl.o add.o search.o cache.o dbcache.o dn2id.o id2entry.o \ +OBJS = idl.o add.o search.o cache.o dbcache.o dn2id.o entry.o id2entry.o \ index.o id2children.o nextid.o abandon.o compare.o group.o \ modify.o modrdn.o delete.o init.o config.o bind.o attr.o \ filterindex.o unbind.o kerberos.o close.o alias.o diff --git a/servers/slapd/back-ldbm/add.c b/servers/slapd/back-ldbm/add.c index 4b929987ae..dbb96e8f22 100644 --- a/servers/slapd/back-ldbm/add.c +++ b/servers/slapd/back-ldbm/add.c @@ -218,8 +218,10 @@ return_results:; ldap_pvt_thread_mutex_unlock(&li->li_root_mutex); } - /* free entry and writer lock */ - cache_return_entry_w( &li->li_cache, e ); + if ( rc ) { + /* free entry and writer lock */ + cache_return_entry_w( &li->li_cache, e ); + } return( rc ); } diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index 4ca59cf035..6ce5693399 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -36,6 +36,7 @@ ldbm_back_initialize( bi->bi_op_delete = ldbm_back_delete; bi->bi_op_abandon = ldbm_back_abandon; + bi->bi_entry_release_rw = ldbm_back_entry_release_rw; #ifdef SLAPD_ACLGROUPS bi->bi_acl_group = ldbm_back_group; #endif diff --git a/servers/slapd/back-ldbm/proto-back-ldbm.h b/servers/slapd/back-ldbm/proto-back-ldbm.h index e64c6a4065..12a8e61869 100644 --- a/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -75,6 +75,11 @@ Entry * dn2entry_rw LDAP_P(( Backend *be, char *dn, char **matched, int rw )); #define dn2entry_r(be, dn, m) dn2entry_rw((be), (dn), (m), 0) #define dn2entry_w(be, dn, m) dn2entry_rw((be), (dn), (m), 1) +/* + * entry.c + */ +int ldbm_back_entry_release_rw LDAP_P(( Backend *be, Entry *e, int rw )); + /* * filterindex.c */ diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index ed09a15ac1..ed106c23e0 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -482,6 +482,21 @@ be_isroot_pw( Backend *be, char *ndn, struct berval *cred ) return result == 0; } +int +be_entry_release_rw( Backend *be, Entry *e, int rw ) +{ + int rc; + + if ( be->be_release ) { + /* free and release entry from backend */ + return be->be_release( be, e, rw ); + } else { + /* free entry */ + entry_free( e ); + return 0; + } +} + int backend_unbind( Connection *conn, diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 1adb6bf5bd..aeb502a41c 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -72,6 +72,10 @@ int be_issuffix LDAP_P(( Backend *be, char *suffix )); int be_isroot LDAP_P(( Backend *be, char *ndn )); int be_isroot_pw LDAP_P(( Backend *be, char *ndn, struct berval *cred )); char* be_root_dn LDAP_P(( Backend *be )); +int be_entry_release_rw LDAP_P(( Backend *be, Entry *e, int rw )); +#define be_entry_release_r( be, e ) be_entry_release_rw( be, e, 0 ) +#define be_entry_release_w( be, e ) be_entry_release_rw( be, e, 1 ) + extern int backend_unbind LDAP_P((Connection *conn, Operation *op)); diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index a7d99114dd..e1a49d40cf 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -249,6 +249,7 @@ struct backend_db { #define be_modrdn bd_info->bi_op_modrdn #define be_search bd_info->bi_op_search +#define be_release bd_info->bi_entry_release_rw #define be_group bd_info->bi_acl_group /* these should be renamed from be_ to bd_ */ @@ -361,6 +362,7 @@ struct backend_info { int msgid)); /* Auxilary Functions */ + int (*bi_entry_release_rw) LDAP_P((BackendDB *bd, Entry *e, int rw)); #ifdef SLAPD_ACLGROUPS int (*bi_acl_group) LDAP_P((Backend *bd, Entry *e, char *bdn, char *edn, -- 2.39.5