1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
/*-
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 1997, 1998, 1999, 2000
* Sleepycat Software. All rights reserved.
*/
#include "db_config.h"
#ifndef lint
static const char revid[] = "$Id: lock_method.c,v 11.5 2000/12/21 19:16:42 bostic Exp $";
#endif /* not lint */
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <string.h>
#endif
#include "db_int.h"
#include "db_shash.h"
#include "lock.h"
/*
* __lock_set_lk_conflicts
* Set the conflicts matrix.
*
* PUBLIC: int __lock_set_lk_conflicts __P((DB_ENV *, u_int8_t *, int));
*/
int
__lock_set_lk_conflicts(dbenv, lk_conflicts, lk_modes)
DB_ENV *dbenv;
u_int8_t *lk_conflicts;
int lk_modes;
{
int ret;
ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_lk_conflicts");
if (dbenv->lk_conflicts != NULL) {
__os_free(dbenv->lk_conflicts,
dbenv->lk_modes * dbenv->lk_modes);
dbenv->lk_conflicts = NULL;
}
if ((ret = __os_malloc(dbenv,
lk_modes * lk_modes, NULL, &dbenv->lk_conflicts)) != 0)
return (ret);
memcpy(dbenv->lk_conflicts, lk_conflicts, lk_modes * lk_modes);
dbenv->lk_modes = lk_modes;
return (0);
}
/*
* __lock_set_lk_detect
* Set the automatic deadlock detection.
*
* PUBLIC: int __lock_set_lk_detect __P((DB_ENV *, u_int32_t));
*/
int
__lock_set_lk_detect(dbenv, lk_detect)
DB_ENV *dbenv;
u_int32_t lk_detect;
{
ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_lk_detect");
switch (lk_detect) {
case DB_LOCK_DEFAULT:
case DB_LOCK_OLDEST:
case DB_LOCK_RANDOM:
case DB_LOCK_YOUNGEST:
break;
default:
return (EINVAL);
}
dbenv->lk_detect = lk_detect;
return (0);
}
/*
* __lock_set_lk_max
* Set the lock table size.
*
* PUBLIC: int __lock_set_lk_max __P((DB_ENV *, u_int32_t));
*/
int
__lock_set_lk_max(dbenv, lk_max)
DB_ENV *dbenv;
u_int32_t lk_max;
{
ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_lk_max");
dbenv->lk_max = lk_max;
dbenv->lk_max_objects = lk_max;
dbenv->lk_max_lockers = lk_max;
return (0);
}
/*
* __lock_set_lk_max_locks
* Set the lock table size.
*
* PUBLIC: int __lock_set_lk_max_locks __P((DB_ENV *, u_int32_t));
*/
int
__lock_set_lk_max_locks(dbenv, lk_max)
DB_ENV *dbenv;
u_int32_t lk_max;
{
ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_lk_max_locks");
dbenv->lk_max = lk_max;
return (0);
}
/*
* __lock_set_lk_max_lockers
* Set the lock table size.
*
* PUBLIC: int __lock_set_lk_max_lockers __P((DB_ENV *, u_int32_t));
*/
int
__lock_set_lk_max_lockers(dbenv, lk_max)
DB_ENV *dbenv;
u_int32_t lk_max;
{
ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_lk_max_lockers");
dbenv->lk_max_lockers = lk_max;
return (0);
}
/*
* __lock_set_lk_max_objects
* Set the lock table size.
*
* PUBLIC: int __lock_set_lk_max_objects __P((DB_ENV *, u_int32_t));
*/
int
__lock_set_lk_max_objects(dbenv, lk_max)
DB_ENV *dbenv;
u_int32_t lk_max;
{
ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_lk_max_objects");
dbenv->lk_max_objects = lk_max;
return (0);
}
|