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.

This commit is contained in:
Bastiaan Bakker 1999-06-23 12:31:35 +00:00
parent 4dfba74846
commit e2b5b21155
11 changed files with 71 additions and 1 deletions

View File

@ -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 );

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 <bcollins@debian.org>, 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;
}

View File

@ -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(

View File

@ -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

View File

@ -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,

View File

@ -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 */
};