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

« back to all changes in this revision

Viewing changes to libdb/env/env_method.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) 1999-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
 
#ifdef HAVE_RPC
18
 
#include <rpc/rpc.h>
19
 
#endif
20
 
 
21
 
#include <string.h>
22
 
#endif
23
 
 
24
 
/*
25
 
 * This is the file that initializes the global array.  Do it this way because
26
 
 * people keep changing one without changing the other.  Having declaration and
27
 
 * initialization in one file will hopefully fix that.
28
 
 */
29
 
#define DB_INITIALIZE_DB_GLOBALS        1
30
 
 
31
 
#include "db_int.h"
32
 
#include "dbinc/crypto.h"
33
 
#include "dbinc/hmac.h"
34
 
#include "dbinc/db_shash.h"
35
 
#include "dbinc/db_page.h"
36
 
#include "dbinc/db_am.h"
37
 
#include "dbinc/lock.h"
38
 
#include "dbinc/log.h"
39
 
#include "dbinc/mp.h"
40
 
#include "dbinc/rep.h"
41
 
#include "dbinc/txn.h"
42
 
 
43
 
#ifdef HAVE_RPC
44
 
#include "dbinc_auto/db_server.h"
45
 
#include "dbinc_auto/rpc_client_ext.h"
46
 
#endif
47
 
 
48
 
static void __dbenv_err __P((const DB_ENV *, int, const char *, ...));
49
 
static void __dbenv_errx __P((const DB_ENV *, const char *, ...));
50
 
static int  __dbenv_init __P((DB_ENV *));
51
 
static int  __dbenv_set_alloc __P((DB_ENV *, void *(*)(size_t),
52
 
    void *(*)(void *, size_t), void (*)(void *)));
53
 
static int  __dbenv_set_app_dispatch __P((DB_ENV *,
54
 
    int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
55
 
static int  __dbenv_set_data_dir __P((DB_ENV *, const char *));
56
 
static int  __dbenv_set_encrypt __P((DB_ENV *, const char *, u_int32_t));
57
 
static void __dbenv_set_errcall __P((DB_ENV *, void (*)(const char *, char *)));
58
 
static void __dbenv_set_errfile __P((DB_ENV *, FILE *));
59
 
static void __dbenv_set_errpfx __P((DB_ENV *, const char *));
60
 
static int  __dbenv_set_feedback __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
61
 
static int  __dbenv_set_flags __P((DB_ENV *, u_int32_t, int));
62
 
static int  __dbenv_set_paniccall __P((DB_ENV *, void (*)(DB_ENV *, int)));
63
 
static int  __dbenv_set_rpc_server_noclnt
64
 
    __P((DB_ENV *, void *, const char *, long, long, u_int32_t));
65
 
static int  __dbenv_set_shm_key __P((DB_ENV *, long));
66
 
static int  __dbenv_set_tas_spins __P((DB_ENV *, u_int32_t));
67
 
static int  __dbenv_set_tmp_dir __P((DB_ENV *, const char *));
68
 
static int  __dbenv_set_verbose __P((DB_ENV *, u_int32_t, int));
69
 
 
70
 
/*
71
 
 * db_env_create --
72
 
 *      DB_ENV constructor.
73
 
 *
74
 
 * EXTERN: int db_env_create __P((DB_ENV **, u_int32_t));
75
 
 */
76
 
int
77
 
db_env_create(dbenvpp, flags)
78
 
        DB_ENV **dbenvpp;
79
 
        u_int32_t flags;
80
 
{
81
 
        DB_ENV *dbenv;
82
 
        int ret;
83
 
 
84
 
        /*
85
 
         * !!!
86
 
         * Our caller has not yet had the opportunity to reset the panic
87
 
         * state or turn off mutex locking, and so we can neither check
88
 
         * the panic state or acquire a mutex in the DB_ENV create path.
89
 
         *
90
 
         * !!!
91
 
         * We can't call the flags-checking routines, we don't have an
92
 
         * environment yet.
93
 
         */
94
 
        if (flags != 0 && flags != DB_CLIENT)
95
 
                return (EINVAL);
96
 
 
97
 
        if ((ret = __os_calloc(NULL, 1, sizeof(*dbenv), &dbenv)) != 0)
98
 
                return (ret);
99
 
 
100
 
#ifdef HAVE_RPC
101
 
        if (LF_ISSET(DB_CLIENT))
102
 
                F_SET(dbenv, DB_ENV_RPCCLIENT);
103
 
#endif
104
 
        ret = __dbenv_init(dbenv);
105
 
 
106
 
        if (ret != 0) {
107
 
                __os_free(NULL, dbenv);
108
 
                return (ret);
109
 
        }
110
 
 
111
 
        *dbenvpp = dbenv;
112
 
        return (0);
113
 
}
114
 
 
115
 
/*
116
 
 * __dbenv_init --
117
 
 *      Initialize a DB_ENV structure.
118
 
 */
119
 
static int
120
 
__dbenv_init(dbenv)
121
 
        DB_ENV *dbenv;
122
 
{
123
 
        /*
124
 
         * !!!
125
 
         * Our caller has not yet had the opportunity to reset the panic
126
 
         * state or turn off mutex locking, and so we can neither check
127
 
         * the panic state or acquire a mutex in the DB_ENV create path.
128
 
         *
129
 
         * Set up methods that are the same in both normal and RPC
130
 
         */
131
 
        dbenv->err = __dbenv_err;
132
 
        dbenv->errx = __dbenv_errx;
133
 
        dbenv->set_errcall = __dbenv_set_errcall;
134
 
        dbenv->set_errfile = __dbenv_set_errfile;
135
 
        dbenv->set_errpfx = __dbenv_set_errpfx;
136
 
 
137
 
#ifdef  HAVE_RPC
138
 
        if (F_ISSET(dbenv, DB_ENV_RPCCLIENT)) {
139
 
                dbenv->close = __dbcl_env_close;
140
 
                dbenv->dbremove = __dbcl_env_dbremove;
141
 
                dbenv->dbrename = __dbcl_env_dbrename;
142
 
                dbenv->open = __dbcl_env_open_wrap;
143
 
                dbenv->remove = __dbcl_env_remove;
144
 
                dbenv->set_alloc = __dbcl_env_alloc;
145
 
                dbenv->set_app_dispatch = __dbcl_set_app_dispatch;
146
 
                dbenv->set_data_dir = __dbcl_set_data_dir;
147
 
                dbenv->set_encrypt = __dbcl_env_encrypt;
148
 
                dbenv->set_feedback = __dbcl_env_set_feedback;
149
 
                dbenv->set_flags = __dbcl_env_flags;
150
 
                dbenv->set_paniccall = __dbcl_env_paniccall;
151
 
                dbenv->set_rpc_server = __dbcl_envrpcserver;
152
 
                dbenv->set_shm_key = __dbcl_set_shm_key;
153
 
                dbenv->set_tas_spins = __dbcl_set_tas_spins;
154
 
                dbenv->set_timeout = __dbcl_set_timeout;
155
 
                dbenv->set_tmp_dir = __dbcl_set_tmp_dir;
156
 
                dbenv->set_verbose = __dbcl_set_verbose;
157
 
        } else {
158
 
#endif
159
 
                dbenv->close = __dbenv_close;
160
 
                dbenv->dbremove = __dbenv_dbremove;
161
 
                dbenv->dbrename = __dbenv_dbrename;
162
 
                dbenv->open = __dbenv_open;
163
 
                dbenv->remove = __dbenv_remove;
164
 
                dbenv->set_alloc = __dbenv_set_alloc;
165
 
                dbenv->set_app_dispatch = __dbenv_set_app_dispatch;
166
 
                dbenv->set_data_dir = __dbenv_set_data_dir;
167
 
                dbenv->set_encrypt = __dbenv_set_encrypt;
168
 
                dbenv->set_feedback = __dbenv_set_feedback;
169
 
                dbenv->set_flags = __dbenv_set_flags;
170
 
                dbenv->set_paniccall = __dbenv_set_paniccall;
171
 
                dbenv->set_rpc_server = __dbenv_set_rpc_server_noclnt;
172
 
                dbenv->set_shm_key = __dbenv_set_shm_key;
173
 
                dbenv->set_tas_spins = __dbenv_set_tas_spins;
174
 
                dbenv->set_tmp_dir = __dbenv_set_tmp_dir;
175
 
                dbenv->set_verbose = __dbenv_set_verbose;
176
 
#ifdef  HAVE_RPC
177
 
        }
178
 
#endif
179
 
        dbenv->shm_key = INVALID_REGION_SEGID;
180
 
        dbenv->db_ref = 0;
181
 
 
182
 
        __log_dbenv_create(dbenv);              /* Subsystem specific. */
183
 
        __lock_dbenv_create(dbenv);
184
 
        __memp_dbenv_create(dbenv);
185
 
        __rep_dbenv_create(dbenv);
186
 
        __txn_dbenv_create(dbenv);
187
 
 
188
 
        return (0);
189
 
}
190
 
 
191
 
/*
192
 
 * __dbenv_err --
193
 
 *      Error message, including the standard error string.
194
 
 */
195
 
static void
196
 
#ifdef __STDC__
197
 
__dbenv_err(const DB_ENV *dbenv, int error, const char *fmt, ...)
198
 
#else
199
 
__dbenv_err(dbenv, error, fmt, va_alist)
200
 
        const DB_ENV *dbenv;
201
 
        int error;
202
 
        const char *fmt;
203
 
        va_dcl
204
 
#endif
205
 
{
206
 
        DB_REAL_ERR(dbenv, error, 1, 1, fmt);
207
 
}
208
 
 
209
 
/*
210
 
 * __dbenv_errx --
211
 
 *      Error message.
212
 
 */
213
 
static void
214
 
#ifdef __STDC__
215
 
__dbenv_errx(const DB_ENV *dbenv, const char *fmt, ...)
216
 
#else
217
 
__dbenv_errx(dbenv, fmt, va_alist)
218
 
        const DB_ENV *dbenv;
219
 
        const char *fmt;
220
 
        va_dcl
221
 
#endif
222
 
{
223
 
        DB_REAL_ERR(dbenv, 0, 0, 1, fmt);
224
 
}
225
 
 
226
 
static int
227
 
__dbenv_set_alloc(dbenv, mal_func, real_func, free_func)
228
 
        DB_ENV *dbenv;
229
 
        void *(*mal_func) __P((size_t));
230
 
        void *(*real_func) __P((void *, size_t));
231
 
        void (*free_func) __P((void *));
232
 
{
233
 
        ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_alloc");
234
 
 
235
 
        dbenv->db_malloc = mal_func;
236
 
        dbenv->db_realloc = real_func;
237
 
        dbenv->db_free = free_func;
238
 
        return (0);
239
 
}
240
 
 
241
 
/*
242
 
 * __dbenv_set_app_dispatch --
243
 
 *      Set the transaction abort recover function.
244
 
 */
245
 
static int
246
 
__dbenv_set_app_dispatch(dbenv, app_dispatch)
247
 
        DB_ENV *dbenv;
248
 
        int (*app_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
249
 
{
250
 
        ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_app_dispatch");
251
 
 
252
 
        dbenv->app_dispatch = app_dispatch;
253
 
        return (0);
254
 
}
255
 
 
256
 
static int
257
 
__dbenv_set_encrypt(dbenv, passwd, flags)
258
 
        DB_ENV *dbenv;
259
 
        const char *passwd;
260
 
        u_int32_t flags;
261
 
{
262
 
#ifdef HAVE_CRYPTO
263
 
        DB_CIPHER *db_cipher;
264
 
        int ret;
265
 
 
266
 
        ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_encrypt");
267
 
#define OK_CRYPTO_FLAGS (DB_ENCRYPT_AES)
268
 
 
269
 
        if (flags != 0 && LF_ISSET(~OK_CRYPTO_FLAGS))
270
 
                return (__db_ferr(dbenv, "DB_ENV->set_encrypt", 0));
271
 
 
272
 
        if (passwd == NULL || strlen(passwd) == 0) {
273
 
                __db_err(dbenv, "Empty password specified to set_encrypt");
274
 
                return (EINVAL);
275
 
        }
276
 
        if (!CRYPTO_ON(dbenv)) {
277
 
                if ((ret = __os_calloc(dbenv, 1, sizeof(DB_CIPHER), &db_cipher))
278
 
                    != 0)
279
 
                        goto err;
280
 
                dbenv->crypto_handle = db_cipher;
281
 
        } else
282
 
                db_cipher = (DB_CIPHER *)dbenv->crypto_handle;
283
 
 
284
 
        if (dbenv->passwd != NULL)
285
 
                __os_free(dbenv, dbenv->passwd);
286
 
        if ((ret = __os_strdup(dbenv, passwd, &dbenv->passwd)) != 0) {
287
 
                __os_free(dbenv, db_cipher);
288
 
                goto err;
289
 
        }
290
 
        /*
291
 
         * We're going to need this often enough to keep around
292
 
         */
293
 
        dbenv->passwd_len = strlen(dbenv->passwd) + 1;
294
 
        /*
295
 
         * The MAC key is for checksumming, and is separate from
296
 
         * the algorithm.  So initialize it here, even if they
297
 
         * are using CIPHER_ANY.
298
 
         */
299
 
        __db_derive_mac((u_int8_t *)dbenv->passwd,
300
 
            dbenv->passwd_len, db_cipher->mac_key);
301
 
        switch (flags) {
302
 
        case 0:
303
 
                F_SET(db_cipher, CIPHER_ANY);
304
 
                break;
305
 
        case DB_ENCRYPT_AES:
306
 
                if ((ret = __crypto_algsetup(dbenv, db_cipher, CIPHER_AES, 0))
307
 
                    != 0)
308
 
                        goto err1;
309
 
                break;
310
 
        }
311
 
        return (0);
312
 
 
313
 
err1:
314
 
        __os_free(dbenv, dbenv->passwd);
315
 
        __os_free(dbenv, db_cipher);
316
 
        dbenv->crypto_handle = NULL;
317
 
err:
318
 
        return (ret);
319
 
#else
320
 
        COMPQUIET(dbenv, NULL);
321
 
        COMPQUIET(passwd, NULL);
322
 
        COMPQUIET(flags, 0);
323
 
 
324
 
        return (__db_eopnotsup(dbenv));
325
 
#endif
326
 
}
327
 
 
328
 
static int
329
 
__dbenv_set_flags(dbenv, flags, onoff)
330
 
        DB_ENV *dbenv;
331
 
        u_int32_t flags;
332
 
        int onoff;
333
 
{
334
 
#define OK_FLAGS                                                        \
335
 
        (DB_AUTO_COMMIT | DB_CDB_ALLDB | DB_DIRECT_DB | DB_DIRECT_LOG | \
336
 
            DB_NOLOCKING | DB_NOMMAP | DB_NOPANIC | DB_OVERWRITE |      \
337
 
            DB_PANIC_ENVIRONMENT | DB_REGION_INIT | DB_TXN_NOSYNC |     \
338
 
            DB_TXN_WRITE_NOSYNC | DB_YIELDCPU)
339
 
 
340
 
        if (LF_ISSET(~OK_FLAGS))
341
 
                return (__db_ferr(dbenv, "DB_ENV->set_flags", 0));
342
 
        if (onoff && LF_ISSET(DB_TXN_WRITE_NOSYNC) && LF_ISSET(DB_TXN_NOSYNC))
343
 
                return (__db_ferr(dbenv, "DB_ENV->set_flags", 1));
344
 
 
345
 
        if (LF_ISSET(DB_AUTO_COMMIT)) {
346
 
                if (onoff)
347
 
                        F_SET(dbenv, DB_ENV_AUTO_COMMIT);
348
 
                else
349
 
                        F_CLR(dbenv, DB_ENV_AUTO_COMMIT);
350
 
        }
351
 
        if (LF_ISSET(DB_CDB_ALLDB)) {
352
 
                ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_flags: DB_CDB_ALLDB");
353
 
                if (onoff)
354
 
                        F_SET(dbenv, DB_ENV_CDB_ALLDB);
355
 
                else
356
 
                        F_CLR(dbenv, DB_ENV_CDB_ALLDB);
357
 
        }
358
 
        if (LF_ISSET(DB_DIRECT_DB)) {
359
 
                if (onoff)
360
 
                        F_SET(dbenv, DB_ENV_DIRECT_DB);
361
 
                else
362
 
                        F_CLR(dbenv, DB_ENV_DIRECT_DB);
363
 
        }
364
 
        if (LF_ISSET(DB_DIRECT_LOG)) {
365
 
                if (onoff)
366
 
                        F_SET(dbenv, DB_ENV_DIRECT_LOG);
367
 
                else
368
 
                        F_CLR(dbenv, DB_ENV_DIRECT_LOG);
369
 
        }
370
 
        if (LF_ISSET(DB_NOLOCKING)) {
371
 
                if (onoff)
372
 
                        F_SET(dbenv, DB_ENV_NOLOCKING);
373
 
                else
374
 
                        F_CLR(dbenv, DB_ENV_NOLOCKING);
375
 
        }
376
 
        if (LF_ISSET(DB_NOMMAP)) {
377
 
                if (onoff)
378
 
                        F_SET(dbenv, DB_ENV_NOMMAP);
379
 
                else
380
 
                        F_CLR(dbenv, DB_ENV_NOMMAP);
381
 
        }
382
 
        if (LF_ISSET(DB_NOPANIC)) {
383
 
                if (onoff)
384
 
                        F_SET(dbenv, DB_ENV_NOPANIC);
385
 
                else
386
 
                        F_CLR(dbenv, DB_ENV_NOPANIC);
387
 
        }
388
 
        if (LF_ISSET(DB_OVERWRITE)) {
389
 
                if (onoff)
390
 
                        F_SET(dbenv, DB_ENV_OVERWRITE);
391
 
                else
392
 
                        F_CLR(dbenv, DB_ENV_OVERWRITE);
393
 
        }
394
 
        if (LF_ISSET(DB_PANIC_ENVIRONMENT)) {
395
 
                ENV_ILLEGAL_BEFORE_OPEN(dbenv,
396
 
                    "set_flags: DB_PANIC_ENVIRONMENT");
397
 
                PANIC_SET(dbenv, onoff);
398
 
        }
399
 
        if (LF_ISSET(DB_REGION_INIT)) {
400
 
                ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_flags: DB_REGION_INIT");
401
 
                if (onoff)
402
 
                        F_SET(dbenv, DB_ENV_REGION_INIT);
403
 
                else
404
 
                        F_CLR(dbenv, DB_ENV_REGION_INIT);
405
 
        }
406
 
        if (LF_ISSET(DB_TXN_NOSYNC)) {
407
 
                if (onoff)
408
 
                        F_SET(dbenv, DB_ENV_TXN_NOSYNC);
409
 
                else
410
 
                        F_CLR(dbenv, DB_ENV_TXN_NOSYNC);
411
 
        }
412
 
        if (LF_ISSET(DB_TXN_WRITE_NOSYNC)) {
413
 
                if (onoff)
414
 
                        F_SET(dbenv, DB_ENV_TXN_WRITE_NOSYNC);
415
 
                else
416
 
                        F_CLR(dbenv, DB_ENV_TXN_WRITE_NOSYNC);
417
 
        }
418
 
        if (LF_ISSET(DB_YIELDCPU)) {
419
 
                if (onoff)
420
 
                        F_SET(dbenv, DB_ENV_YIELDCPU);
421
 
                else
422
 
                        F_CLR(dbenv, DB_ENV_YIELDCPU);
423
 
        }
424
 
        return (0);
425
 
}
426
 
 
427
 
static int
428
 
__dbenv_set_data_dir(dbenv, dir)
429
 
        DB_ENV *dbenv;
430
 
        const char *dir;
431
 
{
432
 
        int ret;
433
 
 
434
 
#define DATA_INIT_CNT   20                      /* Start with 20 data slots. */
435
 
        if (dbenv->db_data_dir == NULL) {
436
 
                if ((ret = __os_calloc(dbenv, DATA_INIT_CNT,
437
 
                    sizeof(char **), &dbenv->db_data_dir)) != 0)
438
 
                        return (ret);
439
 
                dbenv->data_cnt = DATA_INIT_CNT;
440
 
        } else if (dbenv->data_next == dbenv->data_cnt - 1) {
441
 
                dbenv->data_cnt *= 2;
442
 
                if ((ret = __os_realloc(dbenv,
443
 
                    dbenv->data_cnt * sizeof(char **),
444
 
                    &dbenv->db_data_dir)) != 0)
445
 
                        return (ret);
446
 
        }
447
 
        return (__os_strdup(dbenv,
448
 
            dir, &dbenv->db_data_dir[dbenv->data_next++]));
449
 
}
450
 
 
451
 
static void
452
 
__dbenv_set_errcall(dbenv, errcall)
453
 
        DB_ENV *dbenv;
454
 
        void (*errcall) __P((const char *, char *));
455
 
{
456
 
        dbenv->db_errcall = errcall;
457
 
}
458
 
 
459
 
static void
460
 
__dbenv_set_errfile(dbenv, errfile)
461
 
        DB_ENV *dbenv;
462
 
        FILE *errfile;
463
 
{
464
 
        dbenv->db_errfile = errfile;
465
 
}
466
 
 
467
 
static void
468
 
__dbenv_set_errpfx(dbenv, errpfx)
469
 
        DB_ENV *dbenv;
470
 
        const char *errpfx;
471
 
{
472
 
        dbenv->db_errpfx = errpfx;
473
 
}
474
 
 
475
 
static int
476
 
__dbenv_set_feedback(dbenv, feedback)
477
 
        DB_ENV *dbenv;
478
 
        void (*feedback) __P((DB_ENV *, int, int));
479
 
{
480
 
        dbenv->db_feedback = feedback;
481
 
        return (0);
482
 
}
483
 
 
484
 
static int
485
 
__dbenv_set_paniccall(dbenv, paniccall)
486
 
        DB_ENV *dbenv;
487
 
        void (*paniccall) __P((DB_ENV *, int));
488
 
{
489
 
        dbenv->db_paniccall = paniccall;
490
 
        return (0);
491
 
}
492
 
 
493
 
static int
494
 
__dbenv_set_shm_key(dbenv, shm_key)
495
 
        DB_ENV *dbenv;
496
 
        long shm_key;                   /* !!!: really a key_t. */
497
 
{
498
 
        ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_shm_key");
499
 
 
500
 
        dbenv->shm_key = shm_key;
501
 
        return (0);
502
 
}
503
 
 
504
 
static int
505
 
__dbenv_set_tas_spins(dbenv, tas_spins)
506
 
        DB_ENV *dbenv;
507
 
        u_int32_t tas_spins;
508
 
{
509
 
        dbenv->tas_spins = tas_spins;
510
 
        return (0);
511
 
}
512
 
 
513
 
static int
514
 
__dbenv_set_tmp_dir(dbenv, dir)
515
 
        DB_ENV *dbenv;
516
 
        const char *dir;
517
 
{
518
 
        if (dbenv->db_tmp_dir != NULL)
519
 
                __os_free(dbenv, dbenv->db_tmp_dir);
520
 
        return (__os_strdup(dbenv, dir, &dbenv->db_tmp_dir));
521
 
}
522
 
 
523
 
static int
524
 
__dbenv_set_verbose(dbenv, which, onoff)
525
 
        DB_ENV *dbenv;
526
 
        u_int32_t which;
527
 
        int onoff;
528
 
{
529
 
        switch (which) {
530
 
        case DB_VERB_CHKPOINT:
531
 
        case DB_VERB_DEADLOCK:
532
 
        case DB_VERB_RECOVERY:
533
 
        case DB_VERB_REPLICATION:
534
 
        case DB_VERB_WAITSFOR:
535
 
                if (onoff)
536
 
                        FLD_SET(dbenv->verbose, which);
537
 
                else
538
 
                        FLD_CLR(dbenv->verbose, which);
539
 
                break;
540
 
        default:
541
 
                return (EINVAL);
542
 
        }
543
 
        return (0);
544
 
}
545
 
 
546
 
/*
547
 
 * __db_mi_env --
548
 
 *      Method illegally called with public environment.
549
 
 *
550
 
 * PUBLIC: int __db_mi_env __P((DB_ENV *, const char *));
551
 
 */
552
 
int
553
 
__db_mi_env(dbenv, name)
554
 
        DB_ENV *dbenv;
555
 
        const char *name;
556
 
{
557
 
        __db_err(dbenv, "%s: method not permitted in shared environment", name);
558
 
        return (EINVAL);
559
 
}
560
 
 
561
 
/*
562
 
 * __db_mi_open --
563
 
 *      Method illegally called after open.
564
 
 *
565
 
 * PUBLIC: int __db_mi_open __P((DB_ENV *, const char *, int));
566
 
 */
567
 
int
568
 
__db_mi_open(dbenv, name, after)
569
 
        DB_ENV *dbenv;
570
 
        const char *name;
571
 
        int after;
572
 
{
573
 
        __db_err(dbenv, "%s: method not permitted %s open",
574
 
            name, after ? "after" : "before");
575
 
        return (EINVAL);
576
 
}
577
 
 
578
 
/*
579
 
 * __db_env_config --
580
 
 *      Method or function called without required configuration.
581
 
 *
582
 
 * PUBLIC: int __db_env_config __P((DB_ENV *, char *, u_int32_t));
583
 
 */
584
 
int
585
 
__db_env_config(dbenv, i, flags)
586
 
        DB_ENV *dbenv;
587
 
        char *i;
588
 
        u_int32_t flags;
589
 
{
590
 
        char *sub;
591
 
 
592
 
        switch (flags) {
593
 
        case DB_INIT_LOCK:
594
 
                sub = "locking";
595
 
                break;
596
 
        case DB_INIT_LOG:
597
 
                sub = "logging";
598
 
                break;
599
 
        case DB_INIT_MPOOL:
600
 
                sub = "memory pool";
601
 
                break;
602
 
        case DB_INIT_TXN:
603
 
                sub = "transaction";
604
 
                break;
605
 
        default:
606
 
                sub = "<unspecified>";
607
 
                break;
608
 
        }
609
 
        __db_err(dbenv,
610
 
    "%s interface requires an environment configured for the %s subsystem",
611
 
            i, sub);
612
 
        return (EINVAL);
613
 
}
614
 
 
615
 
static int
616
 
__dbenv_set_rpc_server_noclnt(dbenv, cl, host, tsec, ssec, flags)
617
 
        DB_ENV *dbenv;
618
 
        void *cl;
619
 
        const char *host;
620
 
        long tsec, ssec;
621
 
        u_int32_t flags;
622
 
{
623
 
        COMPQUIET(host, NULL);
624
 
        COMPQUIET(cl, NULL);
625
 
        COMPQUIET(tsec, 0);
626
 
        COMPQUIET(ssec, 0);
627
 
        COMPQUIET(flags, 0);
628
 
 
629
 
        __db_err(dbenv,
630
 
            "set_rpc_server method not permitted in non-RPC environment");
631
 
        return (__db_eopnotsup(dbenv));
632
 
}