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

« back to all changes in this revision

Viewing changes to libdb/common/util_cache.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) 2000-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 <stdlib.h>
18
 
 
19
 
#include <string.h>
20
 
#include <unistd.h>
21
 
#endif
22
 
 
23
 
#include "db_int.h"
24
 
 
25
 
/*
26
 
 * __db_util_cache --
27
 
 *      Compute if we have enough cache.
28
 
 *
29
 
 * PUBLIC: int __db_util_cache __P((DB_ENV *, DB *, u_int32_t *, int *));
30
 
 */
31
 
int
32
 
__db_util_cache(dbenv, dbp, cachep, resizep)
33
 
        DB_ENV *dbenv;
34
 
        DB *dbp;
35
 
        u_int32_t *cachep;
36
 
        int *resizep;
37
 
{
38
 
        DBTYPE type;
39
 
        DB_BTREE_STAT *bsp;
40
 
        DB_HASH_STAT *hsp;
41
 
        DB_QUEUE_STAT *qsp;
42
 
        u_int32_t pgsize;
43
 
        int ret;
44
 
        void *sp;
45
 
 
46
 
        /*
47
 
         * The current cache size is in cachep.  If it's insufficient, set the
48
 
         * the memory referenced by resizep to 1 and set cachep to the minimum
49
 
         * size needed.
50
 
         */
51
 
        if ((ret = dbp->get_type(dbp, &type)) != 0) {
52
 
                dbenv->err(dbenv, ret, "DB->get_type");
53
 
                return (ret);
54
 
        }
55
 
 
56
 
        if ((ret = dbp->stat(dbp, &sp, DB_FAST_STAT)) != 0) {
57
 
                dbenv->err(dbenv, ret, "DB->stat");
58
 
                return (ret);
59
 
        }
60
 
 
61
 
        switch (type) {
62
 
        case DB_QUEUE:
63
 
                qsp = (DB_QUEUE_STAT *)sp;
64
 
                pgsize = qsp->qs_pagesize;
65
 
                break;
66
 
        case DB_HASH:
67
 
                hsp = (DB_HASH_STAT *)sp;
68
 
                pgsize = hsp->hash_pagesize;
69
 
                break;
70
 
        case DB_BTREE:
71
 
        case DB_RECNO:
72
 
                bsp = (DB_BTREE_STAT *)sp;
73
 
                pgsize = bsp->bt_pagesize;
74
 
                break;
75
 
        default:
76
 
                dbenv->err(dbenv, ret, "unknown database type: %d", type);
77
 
                return (EINVAL);
78
 
        }
79
 
        free(sp);
80
 
 
81
 
        /*
82
 
         * Make sure our current cache is big enough.  We want at least
83
 
         * DB_MINPAGECACHE pages in the cache.
84
 
         */
85
 
        if ((*cachep / pgsize) < DB_MINPAGECACHE) {
86
 
                *resizep = 1;
87
 
                *cachep = pgsize * DB_MINPAGECACHE;
88
 
        } else
89
 
                *resizep = 0;
90
 
 
91
 
        return (0);
92
 
}