~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/hash/hash_reclaim.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*-
2
 
 * See the file LICENSE for redistribution information.
3
 
 *
4
 
 * Copyright (c) 1996-2002
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 */
7
 
 
8
 
#include "db_config.h"
9
 
 
10
 
#ifndef lint
11
 
static const char revid[] = "$Id$";
12
 
#endif /* not lint */
13
 
 
14
 
#ifndef NO_SYSTEM_INCLUDES
15
 
#include <sys/types.h>
16
 
 
17
 
#include <string.h>
18
 
#endif
19
 
 
20
 
#include "db_int.h"
21
 
#include "dbinc/db_page.h"
22
 
#include "dbinc/hash.h"
23
 
 
24
 
/*
25
 
 * __ham_reclaim --
26
 
 *      Reclaim the pages from a subdatabase and return them to the
27
 
 * parent free list.  For now, we link each freed page on the list
28
 
 * separately.  If people really store hash databases in subdatabases
29
 
 * and do a lot of creates and deletes, this is going to be a problem,
30
 
 * because hash needs chunks of contiguous storage.  We may eventually
31
 
 * need to go to a model where we maintain the free list with chunks of
32
 
 * contiguous pages as well.
33
 
 *
34
 
 * PUBLIC: int __ham_reclaim __P((DB *, DB_TXN *txn));
35
 
 */
36
 
int
37
 
__ham_reclaim(dbp, txn)
38
 
        DB *dbp;
39
 
        DB_TXN *txn;
40
 
{
41
 
        DBC *dbc;
42
 
        HASH_CURSOR *hcp;
43
 
        int ret;
44
 
 
45
 
        /* Open up a cursor that we'll use for traversing. */
46
 
        if ((ret = dbp->cursor(dbp, txn, &dbc, 0)) != 0)
47
 
                return (ret);
48
 
        hcp = (HASH_CURSOR *)dbc->internal;
49
 
 
50
 
        if ((ret = __ham_get_meta(dbc)) != 0)
51
 
                goto err;
52
 
 
53
 
        if ((ret = __ham_traverse(dbc,
54
 
            DB_LOCK_WRITE, __db_reclaim_callback, dbc, 1)) != 0)
55
 
                goto err;
56
 
        if ((ret = dbc->c_close(dbc)) != 0)
57
 
                goto err;
58
 
        if ((ret = __ham_release_meta(dbc)) != 0)
59
 
                goto err;
60
 
        return (0);
61
 
 
62
 
err:    if (hcp->hdr != NULL)
63
 
                (void)__ham_release_meta(dbc);
64
 
        (void)dbc->c_close(dbc);
65
 
        return (ret);
66
 
}
67
 
 
68
 
/*
69
 
 * __ham_truncate --
70
 
 *      Reclaim the pages from a subdatabase and return them to the
71
 
 * parent free list.
72
 
 *
73
 
 * PUBLIC: int __ham_truncate __P((DB *, DB_TXN *txn, u_int32_t *));
74
 
 */
75
 
int
76
 
__ham_truncate(dbp, txn, countp)
77
 
        DB *dbp;
78
 
        DB_TXN *txn;
79
 
        u_int32_t *countp;
80
 
{
81
 
        DBC *dbc;
82
 
        HASH_CURSOR *hcp;
83
 
        db_trunc_param trunc;
84
 
        int ret;
85
 
 
86
 
        /* Open up a cursor that we'll use for traversing. */
87
 
        if ((ret = dbp->cursor(dbp, txn, &dbc, 0)) != 0)
88
 
                return (ret);
89
 
        hcp = (HASH_CURSOR *)dbc->internal;
90
 
 
91
 
        if ((ret = __ham_get_meta(dbc)) != 0)
92
 
                goto err;
93
 
 
94
 
        trunc.count = 0;
95
 
        trunc.dbc = dbc;
96
 
 
97
 
        if ((ret = __ham_traverse(dbc,
98
 
            DB_LOCK_WRITE, __db_truncate_callback, &trunc, 1)) != 0)
99
 
                goto err;
100
 
        if ((ret = __ham_release_meta(dbc)) != 0)
101
 
                goto err;
102
 
        if ((ret = dbc->c_close(dbc)) != 0)
103
 
                goto err;
104
 
        *countp = trunc.count;
105
 
        return (0);
106
 
 
107
 
err:    if (hcp->hdr != NULL)
108
 
                (void)__ham_release_meta(dbc);
109
 
        (void)dbc->c_close(dbc);
110
 
        return (ret);
111
 
}