1999-02-08 19:42:14 +08:00
|
|
|
/* close.c - close bdb2 backend database */
|
1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1999-02-06 00:23:03 +08:00
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/socket.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "back-bdb2.h"
|
|
|
|
|
|
|
|
static int
|
1999-02-08 19:42:14 +08:00
|
|
|
bdb2i_back_db_close_internal( BackendDB *be )
|
1999-02-06 00:23:03 +08:00
|
|
|
{
|
1999-08-18 03:00:59 +08:00
|
|
|
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
|
1999-03-01 19:30:18 +08:00
|
|
|
DB_LOCK lock;
|
|
|
|
|
|
|
|
/* since close will probably write the NEXTID file,
|
|
|
|
wee need transaction control */
|
1999-03-05 18:25:55 +08:00
|
|
|
if ( bdb2i_enter_backend_w( &lock ) != 0 ) {
|
1999-03-01 19:30:18 +08:00
|
|
|
return( -1 );
|
1999-02-06 00:23:03 +08:00
|
|
|
}
|
|
|
|
|
1999-08-18 03:00:59 +08:00
|
|
|
if ( li->li_nextid != NOID ) {
|
1999-03-01 19:30:18 +08:00
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb2 backend saving nextid\n", 0, 0, 0 );
|
|
|
|
if ( bdb2i_next_id_save( be ) < 0 ) {
|
|
|
|
Debug( LDAP_DEBUG_ANY, "bdb2 backend nextid save failed!\n",
|
|
|
|
0, 0, 0 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* before closing all files, leave the backend (thus commiting
|
|
|
|
all writes) and set a last checkpoint */
|
1999-03-05 18:25:55 +08:00
|
|
|
(void) bdb2i_leave_backend_w( lock );
|
|
|
|
(void) bdb2i_set_txn_checkpoint( bdb2i_dbEnv.tx_info, 1 );
|
1999-03-01 19:30:18 +08:00
|
|
|
|
1999-02-08 19:42:14 +08:00
|
|
|
/* close all DB files */
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb2 backend closing DB files\n", 0, 0, 0 );
|
|
|
|
bdb2i_txn_close_files( be );
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "bdb2 backend done closing DB files\n", 0, 0, 0 );
|
1999-02-06 00:23:03 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int
|
1999-02-08 19:42:14 +08:00
|
|
|
bdb2_back_db_close( BackendDB *be )
|
1999-02-06 00:23:03 +08:00
|
|
|
{
|
1999-02-12 22:36:16 +08:00
|
|
|
struct timeval time1;
|
|
|
|
int ret;
|
1999-02-06 00:23:03 +08:00
|
|
|
|
1999-02-12 23:22:43 +08:00
|
|
|
bdb2i_start_timing( be->bd_info, &time1 );
|
1999-02-06 00:23:03 +08:00
|
|
|
|
|
|
|
ret = bdb2i_back_db_close_internal( be );
|
|
|
|
|
1999-02-12 23:22:43 +08:00
|
|
|
bdb2i_stop_timing( be->bd_info, time1, "CLOSE", NULL, NULL );
|
1999-02-06 00:23:03 +08:00
|
|
|
|
|
|
|
return( ret );
|
|
|
|
}
|
|
|
|
|
|
|
|
|