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

« back to all changes in this revision

Viewing changes to libdb/db/crdel_auto.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
 
/* Do not edit: automatically built by gen_rec.awk. */
2
 
#include "db_config.h"
3
 
 
4
 
#ifndef NO_SYSTEM_INCLUDES
5
 
#include <sys/types.h>
6
 
 
7
 
#include <ctype.h>
8
 
#include <string.h>
9
 
#endif
10
 
 
11
 
#include "db_int.h"
12
 
#include "dbinc/crypto.h"
13
 
#include "dbinc/db_page.h"
14
 
#include "dbinc/db_dispatch.h"
15
 
#include "dbinc/db_am.h"
16
 
#include "dbinc/log.h"
17
 
#include "dbinc/rep.h"
18
 
#include "dbinc/txn.h"
19
 
 
20
 
/*
21
 
 * PUBLIC: int __crdel_metasub_log __P((DB *, DB_TXN *, DB_LSN *,
22
 
 * PUBLIC:     u_int32_t, db_pgno_t, const DBT *, DB_LSN *));
23
 
 */
24
 
int
25
 
__crdel_metasub_log(dbp, txnid, ret_lsnp, flags, pgno, page, lsn)
26
 
        DB *dbp;
27
 
        DB_TXN *txnid;
28
 
        DB_LSN *ret_lsnp;
29
 
        u_int32_t flags;
30
 
        db_pgno_t pgno;
31
 
        const DBT *page;
32
 
        DB_LSN * lsn;
33
 
{
34
 
        DBT logrec;
35
 
        DB_ENV *dbenv;
36
 
        DB_LSN *lsnp, null_lsn;
37
 
        u_int32_t zero;
38
 
        u_int32_t uinttmp;
39
 
        u_int32_t npad, rectype, txn_num;
40
 
        int ret;
41
 
        u_int8_t *bp;
42
 
 
43
 
        dbenv = dbp->dbenv;
44
 
        rectype = DB___crdel_metasub;
45
 
        npad = 0;
46
 
 
47
 
        if (txnid == NULL) {
48
 
                txn_num = 0;
49
 
                null_lsn.file = 0;
50
 
                null_lsn.offset = 0;
51
 
                lsnp = &null_lsn;
52
 
        } else {
53
 
                if (TAILQ_FIRST(&txnid->kids) != NULL &&
54
 
                    (ret = __txn_activekids(dbenv, rectype, txnid)) != 0)
55
 
                        return (ret);
56
 
                txn_num = txnid->txnid;
57
 
                lsnp = &txnid->last_lsn;
58
 
        }
59
 
 
60
 
        logrec.size = sizeof(rectype) + sizeof(txn_num) + sizeof(DB_LSN)
61
 
            + sizeof(u_int32_t)
62
 
            + sizeof(u_int32_t)
63
 
            + sizeof(u_int32_t) + (page == NULL ? 0 : page->size)
64
 
            + sizeof(*lsn);
65
 
        if (CRYPTO_ON(dbenv)) {
66
 
                npad =
67
 
                    ((DB_CIPHER *)dbenv->crypto_handle)->adj_size(logrec.size);
68
 
                logrec.size += npad;
69
 
        }
70
 
 
71
 
        if ((ret = __os_malloc(dbenv,
72
 
            logrec.size, &logrec.data)) != 0)
73
 
                return (ret);
74
 
 
75
 
        if (npad > 0)
76
 
                memset((u_int8_t *)logrec.data + logrec.size - npad, 0, npad);
77
 
 
78
 
        bp = logrec.data;
79
 
 
80
 
        memcpy(bp, &rectype, sizeof(rectype));
81
 
        bp += sizeof(rectype);
82
 
 
83
 
        memcpy(bp, &txn_num, sizeof(txn_num));
84
 
        bp += sizeof(txn_num);
85
 
 
86
 
        memcpy(bp, lsnp, sizeof(DB_LSN));
87
 
        bp += sizeof(DB_LSN);
88
 
 
89
 
        DB_ASSERT(dbp->log_filename != NULL);
90
 
        if (dbp->log_filename->id == DB_LOGFILEID_INVALID &&
91
 
            (ret = __dbreg_lazy_id(dbp)) != 0)
92
 
                return (ret);
93
 
 
94
 
        uinttmp = (u_int32_t)dbp->log_filename->id;
95
 
        memcpy(bp, &uinttmp, sizeof(uinttmp));
96
 
        bp += sizeof(uinttmp);
97
 
 
98
 
        uinttmp = (u_int32_t)pgno;
99
 
        memcpy(bp, &uinttmp, sizeof(uinttmp));
100
 
        bp += sizeof(uinttmp);
101
 
 
102
 
        if (page == NULL) {
103
 
                zero = 0;
104
 
                memcpy(bp, &zero, sizeof(u_int32_t));
105
 
                bp += sizeof(u_int32_t);
106
 
        } else {
107
 
                memcpy(bp, &page->size, sizeof(page->size));
108
 
                bp += sizeof(page->size);
109
 
                memcpy(bp, page->data, page->size);
110
 
                bp += page->size;
111
 
        }
112
 
 
113
 
        if (lsn != NULL)
114
 
                memcpy(bp, lsn, sizeof(*lsn));
115
 
        else
116
 
                memset(bp, 0, sizeof(*lsn));
117
 
        bp += sizeof(*lsn);
118
 
 
119
 
        DB_ASSERT((u_int32_t)(bp - (u_int8_t *)logrec.data) <= logrec.size);
120
 
        ret = dbenv->log_put(dbenv,
121
 
           ret_lsnp, (DBT *)&logrec, flags | DB_NOCOPY);
122
 
        if (txnid != NULL && ret == 0)
123
 
                txnid->last_lsn = *ret_lsnp;
124
 
#ifdef LOG_DIAGNOSTIC
125
 
        if (ret != 0)
126
 
                (void)__crdel_metasub_print(dbenv,
127
 
                    (DBT *)&logrec, ret_lsnp, NULL, NULL);
128
 
#endif
129
 
        __os_free(dbenv, logrec.data);
130
 
        return (ret);
131
 
}
132
 
 
133
 
/*
134
 
 * PUBLIC: int __crdel_metasub_getpgnos __P((DB_ENV *, DBT *,
135
 
 * PUBLIC:     DB_LSN *, db_recops, void *));
136
 
 */
137
 
int
138
 
__crdel_metasub_getpgnos(dbenv, rec, lsnp, notused1, summary)
139
 
        DB_ENV *dbenv;
140
 
        DBT *rec;
141
 
        DB_LSN *lsnp;
142
 
        db_recops notused1;
143
 
        void *summary;
144
 
{
145
 
        DB *dbp;
146
 
        TXN_RECS *t;
147
 
        __crdel_metasub_args *argp;
148
 
        u_int32_t ret;
149
 
 
150
 
        COMPQUIET(notused1, DB_TXN_ABORT);
151
 
 
152
 
        argp = NULL;
153
 
        t = (TXN_RECS *)summary;
154
 
 
155
 
        if ((ret = __crdel_metasub_read(dbenv, rec->data, &argp)) != 0)
156
 
                return (ret);
157
 
 
158
 
        if ((ret = __dbreg_id_to_db(dbenv,
159
 
            argp->txnid, &dbp, argp->fileid, 0)) != 0)
160
 
                goto err;
161
 
 
162
 
        if ((ret = __rep_check_alloc(dbenv, t, 1)) != 0)
163
 
                goto err;
164
 
 
165
 
        t->array[t->npages].flags = 0;
166
 
        t->array[t->npages].fid = argp->fileid;
167
 
        t->array[t->npages].lsn = *lsnp;
168
 
        t->array[t->npages].pgdesc.pgno = argp->pgno;
169
 
        t->array[t->npages].pgdesc.type = DB_PAGE_LOCK;
170
 
        memcpy(t->array[t->npages].pgdesc.fileid, dbp->fileid,
171
 
            DB_FILE_ID_LEN);
172
 
        t->npages++;
173
 
 
174
 
err:    if (argp != NULL)
175
 
        __os_free(dbenv, argp);
176
 
        return (ret);
177
 
}
178
 
 
179
 
/*
180
 
 * PUBLIC: int __crdel_metasub_print __P((DB_ENV *, DBT *, DB_LSN *,
181
 
 * PUBLIC:     db_recops, void *));
182
 
 */
183
 
int
184
 
__crdel_metasub_print(dbenv, dbtp, lsnp, notused2, notused3)
185
 
        DB_ENV *dbenv;
186
 
        DBT *dbtp;
187
 
        DB_LSN *lsnp;
188
 
        db_recops notused2;
189
 
        void *notused3;
190
 
{
191
 
        __crdel_metasub_args *argp;
192
 
        u_int32_t i;
193
 
        int ch;
194
 
        int ret;
195
 
 
196
 
        notused2 = DB_TXN_ABORT;
197
 
        notused3 = NULL;
198
 
 
199
 
        if ((ret = __crdel_metasub_read(dbenv, dbtp->data, &argp)) != 0)
200
 
                return (ret);
201
 
        (void)printf(
202
 
            "[%lu][%lu]__crdel_metasub: rec: %lu txnid %lx prevlsn [%lu][%lu]\n",
203
 
            (u_long)lsnp->file,
204
 
            (u_long)lsnp->offset,
205
 
            (u_long)argp->type,
206
 
            (u_long)argp->txnid->txnid,
207
 
            (u_long)argp->prev_lsn.file,
208
 
            (u_long)argp->prev_lsn.offset);
209
 
        (void)printf("\tfileid: %ld\n", (long)argp->fileid);
210
 
        (void)printf("\tpgno: %lu\n", (u_long)argp->pgno);
211
 
        (void)printf("\tpage: ");
212
 
        for (i = 0; i < argp->page.size; i++) {
213
 
                ch = ((u_int8_t *)argp->page.data)[i];
214
 
                printf(isprint(ch) || ch == 0x0a ? "%c" : "%#x ", ch);
215
 
        }
216
 
        (void)printf("\n");
217
 
        (void)printf("\tlsn: [%lu][%lu]\n",
218
 
            (u_long)argp->lsn.file, (u_long)argp->lsn.offset);
219
 
        (void)printf("\n");
220
 
        __os_free(dbenv, argp);
221
 
        return (0);
222
 
}
223
 
 
224
 
/*
225
 
 * PUBLIC: int __crdel_metasub_read __P((DB_ENV *, void *,
226
 
 * PUBLIC:     __crdel_metasub_args **));
227
 
 */
228
 
int
229
 
__crdel_metasub_read(dbenv, recbuf, argpp)
230
 
        DB_ENV *dbenv;
231
 
        void *recbuf;
232
 
        __crdel_metasub_args **argpp;
233
 
{
234
 
        __crdel_metasub_args *argp;
235
 
        u_int32_t uinttmp;
236
 
        u_int8_t *bp;
237
 
        int ret;
238
 
 
239
 
        if ((ret = __os_malloc(dbenv,
240
 
            sizeof(__crdel_metasub_args) + sizeof(DB_TXN), &argp)) != 0)
241
 
                return (ret);
242
 
 
243
 
        argp->txnid = (DB_TXN *)&argp[1];
244
 
 
245
 
        bp = recbuf;
246
 
        memcpy(&argp->type, bp, sizeof(argp->type));
247
 
        bp += sizeof(argp->type);
248
 
 
249
 
        memcpy(&argp->txnid->txnid,  bp, sizeof(argp->txnid->txnid));
250
 
        bp += sizeof(argp->txnid->txnid);
251
 
 
252
 
        memcpy(&argp->prev_lsn, bp, sizeof(DB_LSN));
253
 
        bp += sizeof(DB_LSN);
254
 
 
255
 
        memcpy(&uinttmp, bp, sizeof(uinttmp));
256
 
        argp->fileid = (int32_t)uinttmp;
257
 
        bp += sizeof(uinttmp);
258
 
 
259
 
        memcpy(&uinttmp, bp, sizeof(uinttmp));
260
 
        argp->pgno = (db_pgno_t)uinttmp;
261
 
        bp += sizeof(uinttmp);
262
 
 
263
 
        memset(&argp->page, 0, sizeof(argp->page));
264
 
        memcpy(&argp->page.size, bp, sizeof(u_int32_t));
265
 
        bp += sizeof(u_int32_t);
266
 
        argp->page.data = bp;
267
 
        bp += argp->page.size;
268
 
 
269
 
        memcpy(&argp->lsn, bp,  sizeof(argp->lsn));
270
 
        bp += sizeof(argp->lsn);
271
 
 
272
 
        *argpp = argp;
273
 
        return (0);
274
 
}
275
 
 
276
 
/*
277
 
 * PUBLIC: int __crdel_init_print __P((DB_ENV *, int (***)(DB_ENV *,
278
 
 * PUBLIC:     DBT *, DB_LSN *, db_recops, void *), size_t *));
279
 
 */
280
 
int
281
 
__crdel_init_print(dbenv, dtabp, dtabsizep)
282
 
        DB_ENV *dbenv;
283
 
        int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
284
 
        size_t *dtabsizep;
285
 
{
286
 
        int ret;
287
 
 
288
 
        if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
289
 
            __crdel_metasub_print, DB___crdel_metasub)) != 0)
290
 
                return (ret);
291
 
        return (0);
292
 
}
293
 
 
294
 
/*
295
 
 * PUBLIC: int __crdel_init_getpgnos __P((DB_ENV *,
296
 
 * PUBLIC:     int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *),
297
 
 * PUBLIC:     size_t *));
298
 
 */
299
 
int
300
 
__crdel_init_getpgnos(dbenv, dtabp, dtabsizep)
301
 
        DB_ENV *dbenv;
302
 
        int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
303
 
        size_t *dtabsizep;
304
 
{
305
 
        int ret;
306
 
 
307
 
        if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
308
 
            __crdel_metasub_getpgnos, DB___crdel_metasub)) != 0)
309
 
                return (ret);
310
 
        return (0);
311
 
}
312
 
 
313
 
/*
314
 
 * PUBLIC: int __crdel_init_recover __P((DB_ENV *, int (***)(DB_ENV *,
315
 
 * PUBLIC:     DBT *, DB_LSN *, db_recops, void *), size_t *));
316
 
 */
317
 
int
318
 
__crdel_init_recover(dbenv, dtabp, dtabsizep)
319
 
        DB_ENV *dbenv;
320
 
        int (***dtabp)__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
321
 
        size_t *dtabsizep;
322
 
{
323
 
        int ret;
324
 
 
325
 
        if ((ret = __db_add_recovery(dbenv, dtabp, dtabsizep,
326
 
            __crdel_metasub_recover, DB___crdel_metasub)) != 0)
327
 
                return (ret);
328
 
        return (0);
329
 
}