00001
00002
00003
00004
00005
00006
00007
00008 #include "config.h"
00009
00010 #ifndef lint
00011 static const char revid[] = "$Id: hash__reclaim_8c-source.html,v 1.1 2008/06/08 10:19:38 sebdiaz Exp $";
00012 #endif
00013
00014 #ifndef NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016
00017 #include <errno.h>
00018 #include <string.h>
00019 #endif
00020
00021 #include "db_int.h"
00022 #include "db_page.h"
00023 #include "db_shash.h"
00024 #include "hash.h"
00025 #include "lock.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 int
00040 CDB___ham_reclaim(dbp, txn)
00041 DB *dbp;
00042 DB_TXN *txn;
00043 {
00044 DBC *dbc;
00045 HASH_CURSOR *hcp;
00046 int ret;
00047
00048
00049 if ((ret = dbp->cursor(dbp, txn, &dbc, 0)) != 0)
00050 return (ret);
00051 hcp = (HASH_CURSOR *)dbc->internal;
00052
00053 if ((ret = CDB___ham_get_meta(dbc)) != 0)
00054 goto err;
00055
00056 if ((ret = CDB___ham_traverse(dbp,
00057 dbc, DB_LOCK_WRITE, CDB___db_reclaim_callback, dbc)) != 0)
00058 goto err;
00059 if ((ret = dbc->c_close(dbc)) != 0)
00060 goto err;
00061 if ((ret = CDB___ham_release_meta(dbc)) != 0)
00062 goto err;
00063 return (0);
00064
00065 err: if (hcp->hdr != NULL)
00066 (void)CDB___ham_release_meta(dbc);
00067 (void)dbc->c_close(dbc);
00068 return (ret);
00069 }