return 1;
}
- if ( slapMode & SLAP_TOOL_MODE ) {
- /* No SLAPI plugins for tools, yet... */
- /* When we have DB overlays we will support DB plugins */
- return 0;
- }
-
/* automatically instantiate overlay if necessary */
- if ( !overlay_is_inst( be, SLAPI_OVERLAY_NAME ) ) {
- if ( overlay_config( be, SLAPI_OVERLAY_NAME ) != 0 ) {
+ if ( !slapi_over_is_inst( be ) ) {
+ if ( slapi_over_config( be ) != 0 ) {
fprintf( stderr, "Failed to instantiate SLAPI overlay\n");
return -1;
}
}
}
-int
-slapi_int_initialize(void)
-{
- if ( ldap_pvt_thread_mutex_init( &slapi_hn_mutex ) ) {
- return -1;
- }
-
- if ( ldap_pvt_thread_mutex_init( &slapi_time_mutex ) ) {
- return -1;
- }
-
- if ( ldap_pvt_thread_mutex_init( &slapi_printmessage_mutex ) ) {
- return -1;
- }
-
- slapi_log_file = slapi_ch_strdup( LDAP_RUNDIR LDAP_DIRSEP "errors" );
- if ( slapi_log_file == NULL ) {
- return -1;
- }
-
- if ( slapi_int_init_object_extensions() != 0 ) {
- return -1;
- }
-
- return slapi_int_overlay_init();
-}
#ifdef LDAP_SLAPI
static slap_overinst slapi;
+static int slapi_over_initialized = 0;
static int slapi_over_response( Operation *op, SlapReply *rs );
static int slapi_over_cleanup( Operation *op, SlapReply *rs );
slap_callback cb;
int internal_op;
int preop_type, postop_type;
+ BackendDB *be;
if ( !slapi_plugins_used )
return SLAP_CB_CONTINUE;
pb = SLAPI_OPERATION_PBLOCK( op );
- rc = slapi_int_call_plugins( op->o_bd, preop_type, pb );
+ /* cache backend so we call correct postop plugins */
+ be = pb->pb_op->o_bd;
+
+ rc = slapi_int_call_plugins( be, preop_type, pb );
/*
* soi_callback is responsible for examining the result code
/*
* Call postoperation plugins
*/
- slapi_int_call_plugins( op->o_bd, postop_type, pb );
+ slapi_int_call_plugins( be, postop_type, pb );
cleanup:
if ( !internal_op ) {
return rc;
}
-int
-slapi_int_overlay_init()
+static int
+slapi_over_init()
{
memset( &slapi, 0, sizeof(slapi) );
return overlay_register( &slapi );
}
+int slapi_over_is_inst( BackendDB *be )
+{
+ return overlay_is_inst( be, SLAPI_OVERLAY_NAME );
+}
+
+int slapi_over_config( BackendDB *be )
+{
+ if ( slapi_over_initialized == 0 ) {
+ int rc;
+
+ /* do global initializaiton */
+ ldap_pvt_thread_mutex_init( &slapi_hn_mutex );
+ ldap_pvt_thread_mutex_init( &slapi_time_mutex );
+ ldap_pvt_thread_mutex_init( &slapi_printmessage_mutex );
+
+ slapi_log_file = slapi_ch_strdup( LDAP_RUNDIR LDAP_DIRSEP "errors" );
+
+ rc = slapi_int_init_object_extensions();
+ if ( rc != 0 )
+ return rc;
+
+ rc = slapi_over_init();
+ if ( rc != 0 )
+ return rc;
+
+ slapi_over_initialized = 1;
+ }
+
+ return overlay_config( be, SLAPI_OVERLAY_NAME );
+}
+
#endif /* LDAP_SLAPI */