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

« back to all changes in this revision

Viewing changes to libdb/libdb_java/java_DbLogc.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) 1997-2002
5
 
 *      Sleepycat Software.  All rights reserved.
6
 
 */
7
 
#include "db_config.h"
8
 
 
9
 
#ifndef lint
10
 
static const char revid[] = "$Id$";
11
 
#endif /* not lint */
12
 
 
13
 
#include <jni.h>
14
 
#include <errno.h>
15
 
#include <stdlib.h>
16
 
#include <string.h>
17
 
#ifdef DIAGNOSTIC
18
 
#include <stdio.h>
19
 
#endif
20
 
 
21
 
#include "db_int.h"
22
 
#include "java_util.h"
23
 
#include "com_sleepycat_db_DbLogc.h"
24
 
 
25
 
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLogc_close
26
 
  (JNIEnv *jnienv, jobject jthis, jint flags)
27
 
{
28
 
        int err;
29
 
        DB_LOGC *dblogc = get_DB_LOGC(jnienv, jthis);
30
 
 
31
 
        if (!verify_non_null(jnienv, dblogc))
32
 
                return;
33
 
        err = dblogc->close(dblogc, flags);
34
 
        if (verify_return(jnienv, err, 0)) {
35
 
                set_private_dbobj(jnienv, name_DB_LOGC, jthis, 0);
36
 
        }
37
 
}
38
 
 
39
 
JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbLogc_get
40
 
  (JNIEnv *jnienv, jobject jthis,
41
 
   /*DbLsn*/ jobject lsn, /*Dbt*/ jobject data, jint flags)
42
 
{
43
 
        int err, retry;
44
 
        DB_LOGC *dblogc;
45
 
        DB_LSN *dblsn;
46
 
        LOCKED_DBT ldata;
47
 
        OpKind dataop;
48
 
 
49
 
        /*
50
 
         * Depending on flags, the user may be supplying the key,
51
 
         * or else we may have to retrieve it.
52
 
         */
53
 
        err = 0;
54
 
        dataop = outOp;
55
 
 
56
 
        dblogc = get_DB_LOGC(jnienv, jthis);
57
 
        dblsn = get_DB_LSN(jnienv, lsn);
58
 
        if (locked_dbt_get(&ldata, jnienv, dblogc->dbenv, data, dataop) != 0)
59
 
                goto out1;
60
 
 
61
 
        if (!verify_non_null(jnienv, dblogc))
62
 
                goto out1;
63
 
 
64
 
        for (retry = 0; retry < 3; retry++) {
65
 
                err = dblogc->get(dblogc, dblsn, &ldata.javainfo->dbt, flags);
66
 
 
67
 
                /*
68
 
                 * If we failed due to lack of memory in our DBT arrays,
69
 
                 * retry.
70
 
                 */
71
 
                if (err != ENOMEM)
72
 
                        break;
73
 
                if (!locked_dbt_realloc(&ldata, jnienv, dblogc->dbenv))
74
 
                        break;
75
 
        }
76
 
 out1:
77
 
        locked_dbt_put(&ldata, jnienv, dblogc->dbenv);
78
 
        if (!DB_RETOK_LGGET(err)) {
79
 
                if (verify_dbt(jnienv, err, &ldata))
80
 
                        verify_return(jnienv, err, 0);
81
 
        }
82
 
        return (err);
83
 
}
84
 
 
85
 
JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLogc_finalize
86
 
  (JNIEnv *jnienv, jobject jthis)
87
 
{
88
 
        /*
89
 
         * Free any data related to DB_LOGC here.
90
 
         * If we ever have java-only data embedded in the DB_LOGC
91
 
         * and need to do this, we'll have to track DbLogc's
92
 
         * according to which DbEnv owns them, just as
93
 
         * we track Db's according to which DbEnv owns them.
94
 
         * That's necessary to avoid double freeing that
95
 
         * comes about when closes interact with GC.
96
 
         */
97
 
 
98
 
#ifdef DIAGNOSTIC
99
 
        DB_LOGC *dblogc;
100
 
 
101
 
        dblogc = get_DB_LOGC(jnienv, jthis);
102
 
        if (dblogc != NULL)
103
 
                fprintf(stderr, "Java API: DbLogc has not been closed\n");
104
 
#else
105
 
 
106
 
        COMPQUIET(jnienv, NULL);
107
 
        COMPQUIET(jthis, NULL);
108
 
 
109
 
#endif
110
 
}