+ /* open each backend database */
+ for( i = 0; i < nBackendDB; i++ ) {
+ if ( backendDB[i].bd_info->bi_db_open ) {
+ rc = backendDB[i].bd_info->bi_db_open(
+ &backendDB[i] );
+ }
+
+ if(rc != 0) {
+ Debug( LDAP_DEBUG_ANY,
+ "backend_startup: bi_db_open %d failed!\n",
+ i, 0, 0 );
+ return rc;
+ }
+ }
+
+ return rc;
+}
+
+int backend_shutdown(int n)
+{
+ int i;
+ int rc = 0;
+
+ if(n >= 0) {
+ /* shutdown a specific backend database */
+
+ /* make sure, n does not exceed the number of backend databases */
+ if ( n >= nbackends ) {
+
+ Debug( LDAP_DEBUG_ANY,
+ "backend_startup: database number %d exceeding maximum (%d)\n",
+ n, nbackends, 0 );
+ return 1;
+ }
+
+ if ( backendDB[n].bd_info->bi_nDB == 0 ) {
+ /* no database of this type, we never opened it */
+ return 0;
+ }
+
+ if ( backendDB[n].bd_info->bi_db_close ) {
+ backendDB[n].bd_info->bi_db_close(
+ &backendDB[n] );
+ }
+
+ if( backendDB[n].bd_info->bi_close ) {
+ backendDB[n].bd_info->bi_close(
+ backendDB[n].bd_info );
+ }
+
+ return 0;
+ }
+
+ /* close each backend database */
+ for( i = 0; i < nBackendDB; i++ ) {
+ BackendInfo *bi;
+
+ if ( backendDB[i].bd_info->bi_db_close ) {
+ backendDB[i].bd_info->bi_db_close(
+ &backendDB[i] );
+ }
+
+ if(rc != 0) {
+ Debug( LDAP_DEBUG_ANY,
+ "backend_close: bi_close %s failed!\n",
+ bi->bi_type, 0, 0 );
+ }
+ }
+
+ /* close each backend type */
+ for( i = 0; i < nBackendInfo; i++ ) {
+ if( backendInfo[i].bi_nDB == 0 ) {
+ /* no database of this type */
+ continue;
+ }
+
+ if( backendInfo[i].bi_close ) {
+ backendInfo[i].bi_close(
+ &backendInfo[i] );
+ }
+ }