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

« back to all changes in this revision

Viewing changes to libdb/txn/txn_stat.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/txn.h"
22
 
 
23
 
/*
24
 
 * __txn_stat --
25
 
 *
26
 
 * PUBLIC: int __txn_stat __P((DB_ENV *, DB_TXN_STAT **, u_int32_t));
27
 
 */
28
 
int
29
 
__txn_stat(dbenv, statp, flags)
30
 
        DB_ENV *dbenv;
31
 
        DB_TXN_STAT **statp;
32
 
        u_int32_t flags;
33
 
{
34
 
        DB_TXNMGR *mgr;
35
 
        DB_TXNREGION *region;
36
 
        DB_TXN_STAT *stats;
37
 
        TXN_DETAIL *txnp;
38
 
        size_t nbytes;
39
 
        u_int32_t ndx;
40
 
        int ret;
41
 
 
42
 
        PANIC_CHECK(dbenv);
43
 
        ENV_REQUIRES_CONFIG(dbenv, dbenv->tx_handle, "txn_stat", DB_INIT_TXN);
44
 
 
45
 
        *statp = NULL;
46
 
        if ((ret = __db_fchk(dbenv,
47
 
            "DB_ENV->txn_stat", flags, DB_STAT_CLEAR)) != 0)
48
 
                return (ret);
49
 
 
50
 
        mgr = dbenv->tx_handle;
51
 
        region = mgr->reginfo.primary;
52
 
 
53
 
        /*
54
 
         * Allocate for the maximum active transactions -- the DB_TXN_ACTIVE
55
 
         * struct is small and the maximum number of active transactions is
56
 
         * not going to be that large.  Don't have to lock anything to look
57
 
         * at the region's maximum active transactions value, it's read-only
58
 
         * and never changes after the region is created.
59
 
         */
60
 
        nbytes = sizeof(DB_TXN_STAT) + sizeof(DB_TXN_ACTIVE) * region->maxtxns;
61
 
        if ((ret = __os_umalloc(dbenv, nbytes, &stats)) != 0)
62
 
                return (ret);
63
 
 
64
 
        R_LOCK(dbenv, &mgr->reginfo);
65
 
        memcpy(stats, &region->stat, sizeof(*stats));
66
 
        stats->st_last_txnid = region->last_txnid;
67
 
        stats->st_last_ckp = region->last_ckp;
68
 
        stats->st_time_ckp = region->time_ckp;
69
 
        stats->st_txnarray = (DB_TXN_ACTIVE *)&stats[1];
70
 
 
71
 
        ndx = 0;
72
 
        for (txnp = SH_TAILQ_FIRST(&region->active_txn, __txn_detail);
73
 
            txnp != NULL;
74
 
            txnp = SH_TAILQ_NEXT(txnp, links, __txn_detail)) {
75
 
                stats->st_txnarray[ndx].txnid = txnp->txnid;
76
 
                if (txnp->parent == INVALID_ROFF)
77
 
                        stats->st_txnarray[ndx].parentid = TXN_INVALID;
78
 
                else
79
 
                        stats->st_txnarray[ndx].parentid =
80
 
                            ((TXN_DETAIL *)R_ADDR(&mgr->reginfo,
81
 
                            txnp->parent))->txnid;
82
 
                stats->st_txnarray[ndx].lsn = txnp->begin_lsn;
83
 
                ndx++;
84
 
        }
85
 
 
86
 
        stats->st_region_wait = mgr->reginfo.rp->mutex.mutex_set_wait;
87
 
        stats->st_region_nowait = mgr->reginfo.rp->mutex.mutex_set_nowait;
88
 
        stats->st_regsize = mgr->reginfo.rp->size;
89
 
        if (LF_ISSET(DB_STAT_CLEAR)) {
90
 
                mgr->reginfo.rp->mutex.mutex_set_wait = 0;
91
 
                mgr->reginfo.rp->mutex.mutex_set_nowait = 0;
92
 
                memset(&region->stat, 0, sizeof(region->stat));
93
 
                region->stat.st_maxtxns = region->maxtxns;
94
 
                region->stat.st_maxnactive =
95
 
                    region->stat.st_nactive = stats->st_nactive;
96
 
        }
97
 
 
98
 
        R_UNLOCK(dbenv, &mgr->reginfo);
99
 
 
100
 
        *statp = stats;
101
 
        return (0);
102
 
}