int bdb_tool_entry_close( BackendDB *be ) { if ( bdb_tool_info ) { slapd_shutdown = 1; ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex ); ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond ); ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex ); ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex ); bdb_tool_index_tcount = slap_tool_thread_max - 1; ldap_pvt_thread_cond_broadcast( &bdb_tool_index_cond_work ); ldap_pvt_thread_mutex_unlock( &bdb_tool_index_mutex ); } if( eh.bv.bv_val ) { ch_free( eh.bv.bv_val ); eh.bv.bv_val = NULL; } if( cursor ) { cursor->c_close( cursor ); cursor = NULL; } #ifdef BDB_TOOL_IDL_CACHING bdb_tool_idl_flush( be ); #endif if( nholes ) { unsigned i; fprintf( stderr, "Error, entries missing!\n"); for (i=0; i<nholes; i++) { fprintf(stderr, " entry %ld: %s\n", holes[i].id, holes[i].dn.bv_val); } return -1; } return 0; }
int bdb_tool_entry_close( BackendDB *be ) { if ( bdb_tool_info ) { slapd_shutdown = 1; #ifdef USE_TRICKLE ldap_pvt_thread_mutex_lock( &bdb_tool_trickle_mutex ); /* trickle thread may not have started yet */ while ( !bdb_tool_trickle_active ) ldap_pvt_thread_cond_wait( &bdb_tool_trickle_cond_end, &bdb_tool_trickle_mutex ); ldap_pvt_thread_cond_signal( &bdb_tool_trickle_cond ); while ( bdb_tool_trickle_active ) ldap_pvt_thread_cond_wait( &bdb_tool_trickle_cond_end, &bdb_tool_trickle_mutex ); ldap_pvt_thread_mutex_unlock( &bdb_tool_trickle_mutex ); #endif if ( bdb_tool_threads > 1 ) { ldap_pvt_thread_mutex_lock( &bdb_tool_index_mutex ); /* There might still be some threads starting */ while ( bdb_tool_index_tcount > 0 ) { ldap_pvt_thread_cond_wait( &bdb_tool_index_cond_main, &bdb_tool_index_mutex ); } bdb_tool_index_tcount = bdb_tool_threads - 1; ldap_pvt_thread_cond_broadcast( &bdb_tool_index_cond_work ); /* Make sure all threads are stopped */ while ( bdb_tool_index_tcount > 0 ) { ldap_pvt_thread_cond_wait( &bdb_tool_index_cond_main, &bdb_tool_index_mutex ); } ldap_pvt_thread_mutex_unlock( &bdb_tool_index_mutex ); ch_free( bdb_tool_index_threads ); ch_free( bdb_tool_index_rec ); bdb_tool_index_tcount = bdb_tool_threads - 1; } bdb_tool_info = NULL; slapd_shutdown = 0; } if( eh.bv.bv_val ) { ch_free( eh.bv.bv_val ); eh.bv.bv_val = NULL; } if( cursor ) { cursor->c_close( cursor ); cursor = NULL; } #ifdef BDB_TOOL_IDL_CACHING bdb_tool_idl_flush( be ); #endif if( nholes ) { unsigned i; fprintf( stderr, "Error, entries missing!\n"); for (i=0; i<nholes; i++) { fprintf(stderr, " entry %ld: %s\n", holes[i].id, holes[i].dn.bv_val); } return -1; } return 0; }