X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fmodule.c;h=8f8b9c60de14dba46a9ae8667edc356c704bb52d;hb=76c6c8e5b7f7731440872010b895cd30c8076b59;hp=71e1b22200ff62c12c154455787722b29e9b7d79;hpb=af985c7efb1069ae1062d991b6b9fc90acb47747;p=openldap diff --git a/servers/slapd/module.c b/servers/slapd/module.c index 71e1b22200..8f8b9c60de 100644 --- a/servers/slapd/module.c +++ b/servers/slapd/module.c @@ -1,7 +1,7 @@ /* $OpenLDAP$ */ /* This work is part of OpenLDAP Software . * - * Copyright 1998-2007 The OpenLDAP Foundation. + * Copyright 1998-2011 The OpenLDAP Foundation. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -119,7 +119,7 @@ int module_unload( const char *file_name ) int module_load(const char* file_name, int argc, char *argv[]) { - module_loaded_t *module = NULL; + module_loaded_t *module; const char *error; int rc; MODULE_INIT_FN initialize; @@ -129,6 +129,38 @@ int module_load(const char* file_name, int argc, char *argv[]) #define file file_name #endif + module = module_handle( file_name ); + if ( module ) { + Debug( LDAP_DEBUG_ANY, "module_load: (%s) already loaded\n", + file_name, 0, 0 ); + return -1; + } + + /* If loading a backend, see if we already have it */ + if ( !strncasecmp( file_name, "back_", 5 )) { + char *name = (char *)file_name + 5; + char *dot = strchr( name, '.'); + if (dot) *dot = '\0'; + rc = backend_info( name ) != NULL; + if (dot) *dot = '.'; + if ( rc ) { + Debug( LDAP_DEBUG_CONFIG, "module_load: (%s) already present (static)\n", + file_name, 0, 0 ); + return 0; + } + } else { + /* check for overlays too */ + char *dot = strchr( file_name, '.' ); + if ( dot ) *dot = '\0'; + rc = overlay_find( file_name ) != NULL; + if ( dot ) *dot = '.'; + if ( rc ) { + Debug( LDAP_DEBUG_CONFIG, "module_load: (%s) already present (static)\n", + file_name, 0, 0 ); + return 0; + } + } + module = (module_loaded_t *)ch_calloc(1, sizeof(module_loaded_t) + strlen(file_name)); if (module == NULL) {