From e2b5b211558ee778f07954d3843b914f19f6c6b5 Mon Sep 17 00:00:00 2001 From: Bastiaan Bakker Date: Wed, 23 Jun 1999 12:31:35 +0000 Subject: [PATCH] Added connection initialisation and destruction notification. Now backends can register functions in backend_info.bi_connection_init and backend_info.bi_connection_destroy that will be called when a connection is initialized or destroyed. --- servers/slapd/back-bdb2/init.c | 3 +++ servers/slapd/back-ldap/init.c | 3 +++ servers/slapd/back-ldbm/init.c | 3 +++ servers/slapd/back-passwd/init.c | 3 +++ servers/slapd/back-perl/init.c | 3 +++ servers/slapd/back-shell/init.c | 3 +++ servers/slapd/back-tcl/tcl_init.c | 5 ++++- servers/slapd/backend.c | 32 +++++++++++++++++++++++++++++++ servers/slapd/connection.c | 4 ++++ servers/slapd/proto-slap.h | 3 +++ servers/slapd/slap.h | 10 ++++++++++ 11 files changed, 71 insertions(+), 1 deletion(-) diff --git a/servers/slapd/back-bdb2/init.c b/servers/slapd/back-bdb2/init.c index 396812ecda..6fc605014e 100644 --- a/servers/slapd/back-bdb2/init.c +++ b/servers/slapd/back-bdb2/init.c @@ -66,6 +66,9 @@ bdb2_back_initialize( bi->bi_acl_group = bdb2_back_group; #endif + bi->bi_connection_init = 0; + bi->bi_connection_destroy = 0; + ret = bdb2i_back_init_private( bi ); Debug( LDAP_DEBUG_TRACE, "bdb2_back_initialize: done (%d).\n", ret, 0, 0 ); diff --git a/servers/slapd/back-ldap/init.c b/servers/slapd/back-ldap/init.c index 0665262b75..e625d50e68 100644 --- a/servers/slapd/back-ldap/init.c +++ b/servers/slapd/back-ldap/init.c @@ -60,6 +60,9 @@ ldap_back_initialize( bi->bi_acl_group = 0; #endif + bi->bi_connection_init = 0; + bi->bi_connection_destroy = 0; + return 0; } diff --git a/servers/slapd/back-ldbm/init.c b/servers/slapd/back-ldbm/init.c index 34bceb7967..67f40f83a5 100644 --- a/servers/slapd/back-ldbm/init.c +++ b/servers/slapd/back-ldbm/init.c @@ -41,6 +41,9 @@ ldbm_back_initialize( bi->bi_acl_group = ldbm_back_group; #endif + bi->bi_connection_init = 0; + bi->bi_connection_destroy = 0; + return 0; } diff --git a/servers/slapd/back-passwd/init.c b/servers/slapd/back-passwd/init.c index ec01e90289..b0605f5513 100644 --- a/servers/slapd/back-passwd/init.c +++ b/servers/slapd/back-passwd/init.c @@ -39,5 +39,8 @@ passwd_back_initialize( bi->bi_acl_group = 0; #endif + bi->bi_connection_init = 0; + bi->bi_connection_destroy = 0; + return 0; } diff --git a/servers/slapd/back-perl/init.c b/servers/slapd/back-perl/init.c index 59fecd7d6d..4717b6f199 100644 --- a/servers/slapd/back-perl/init.c +++ b/servers/slapd/back-perl/init.c @@ -80,6 +80,9 @@ perl_back_initialize( bi->bi_acl_group = 0; #endif + bi->bi_connection_init = 0; + bi->bi_connection_destroy = 0; + return 0; } diff --git a/servers/slapd/back-shell/init.c b/servers/slapd/back-shell/init.c index 261c795210..b73c96648f 100644 --- a/servers/slapd/back-shell/init.c +++ b/servers/slapd/back-shell/init.c @@ -39,6 +39,9 @@ shell_back_initialize( bi->bi_acl_group = 0; #endif + bi->bi_connection_init = 0; + bi->bi_connection_destroy = 0; + return 0; } diff --git a/servers/slapd/back-tcl/tcl_init.c b/servers/slapd/back-tcl/tcl_init.c index 925ce14f41..4af70c4e28 100644 --- a/servers/slapd/back-tcl/tcl_init.c +++ b/servers/slapd/back-tcl/tcl_init.c @@ -1,6 +1,6 @@ /* tcl_init.c - tcl backend initialization * - * $Id: tcl_init.c,v 1.5 1999/02/20 07:53:48 hallvard Exp $ + * $Id: tcl_init.c,v 1.6 1999/03/03 16:02:10 hallvard Exp $ * * Copyright 1999, Ben Collins , All rights reserved. * @@ -63,6 +63,9 @@ tcl_back_initialize ( bi->bi_acl_group = 0; #endif + bi->bi_connection_init = 0; + bi->bi_connection_destroy = 0; + return 0; } diff --git a/servers/slapd/backend.c b/servers/slapd/backend.c index 716fac39fc..eb0e3a3194 100644 --- a/servers/slapd/backend.c +++ b/servers/slapd/backend.c @@ -518,6 +518,38 @@ backend_unbind( return 0; } +int +backend_connection_init( + Connection *conn +) +{ + int i; + + for ( i = 0; i < nbackends; i++ ) { + if ( backends[i].be_connection_init ) { + (*backends[i].be_connection_init)( &backends[i], conn); + } + } + + return 0; +} + +int +backend_connection_destroy( + Connection *conn +) +{ + int i; + + for ( i = 0; i < nbackends; i++ ) { + if ( backends[i].be_connection_destroy ) { + (*backends[i].be_connection_destroy)( &backends[i], conn); + } + } + + return 0; +} + #ifdef SLAPD_ACLGROUPS int backend_group( diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 3cc267347f..213f3f45d2 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -374,6 +374,8 @@ long connection_init( ldap_pvt_thread_mutex_unlock( &c->c_mutex ); ldap_pvt_thread_mutex_unlock( &connections_mutex ); + backend_connection_init(c); + return id; } @@ -388,6 +390,8 @@ connection_destroy( Connection *c ) assert( c->c_conn_state != SLAP_C_INVALID ); assert( c->c_ops == NULL ); + backend_connection_destroy(c); + #ifdef LDAP_COMPAT30 c->c_version = 0; #endif diff --git a/servers/slapd/proto-slap.h b/servers/slapd/proto-slap.h index 58e92c964a..0d461d63b5 100644 --- a/servers/slapd/proto-slap.h +++ b/servers/slapd/proto-slap.h @@ -89,6 +89,9 @@ int be_entry_release_rw LDAP_P(( Backend *be, Entry *e, int rw )); extern int backend_unbind LDAP_P((Connection *conn, Operation *op)); +extern int backend_connection_init LDAP_P((Connection *conn)); +extern int backend_connection_destroy LDAP_P((Connection *conn)); + extern int backend_group LDAP_P((Backend *be, Entry *target, char *gr_ndn, char *op_ndn, diff --git a/servers/slapd/slap.h b/servers/slapd/slap.h index cd89c3687f..99e9747df5 100644 --- a/servers/slapd/slap.h +++ b/servers/slapd/slap.h @@ -341,6 +341,10 @@ struct backend_db { #define be_release bd_info->bi_entry_release_rw #define be_group bd_info->bi_acl_group +#define be_connection_init bd_info->bi_connection_init +#define be_connection_destroy bd_info->bi_connection_destroy + + /* these should be renamed from be_ to bd_ */ char **be_suffix; /* the DN suffixes of data in this backend */ char **be_nsuffix; /* the normalized DN suffixes in this backend */ @@ -461,6 +465,12 @@ struct backend_info { char *objectclassValue, char *groupattrName )); #endif + int (*bi_connection_init) LDAP_P((BackendDB *bd, + struct slap_conn *c)); + int (*bi_connection_destroy) LDAP_P((BackendDB *bd, + struct slap_conn *c)); + + unsigned int bi_nDB; /* number of databases of this type */ void *bi_private; /* anything the backend type needs */ }; -- 2.39.5