1 | /* solaris */ |
1 | #include <sys/user.h> |
2 | #define _POSIX_PTHREAD_SEMANTICS 1 |
2 | #include <sys/ptrace.h> |
3 | |
3 | |
4 | #if __linux && !defined(_GNU_SOURCE) |
4 | #define X_STACKSIZE 1024 * 128 + sizeof (long) * 64 * 1024 / 4 |
5 | # define _GNU_SOURCE |
|
|
6 | #endif |
|
|
7 | |
5 | |
8 | /* just in case */ |
6 | #include "xthread.h" |
9 | #define _REENTRANT 1 |
|
|
10 | |
7 | |
11 | #include <errno.h> |
8 | #include <errno.h> |
12 | |
9 | |
13 | #include "EXTERN.h" |
10 | #include "EXTERN.h" |
14 | #include "perl.h" |
11 | #include "perl.h" |
15 | #include "XSUB.h" |
12 | #include "XSUB.h" |
16 | |
13 | |
17 | #include <pthread.h> |
14 | // perl stupidly defines these as macros, breaking |
|
|
15 | // lots and lots of code. |
|
|
16 | #undef open |
|
|
17 | #undef close |
|
|
18 | #undef abort |
|
|
19 | #undef malloc |
|
|
20 | #undef free |
|
|
21 | #undef send |
18 | |
22 | |
19 | #include <stddef.h> |
23 | #include <stddef.h> |
20 | #include <stdlib.h> |
24 | #include <stdlib.h> |
21 | #include <errno.h> |
25 | #include <errno.h> |
22 | #include <sys/time.h> |
|
|
23 | #include <sys/types.h> |
26 | #include <sys/types.h> |
24 | #include <limits.h> |
27 | #include <limits.h> |
25 | #include <unistd.h> |
|
|
26 | #include <fcntl.h> |
28 | #include <fcntl.h> |
27 | |
29 | |
|
|
30 | #ifndef _WIN32 |
|
|
31 | # include <sys/time.h> |
|
|
32 | # include <unistd.h> |
|
|
33 | #endif |
|
|
34 | |
28 | #include <db.h> |
35 | #include <db.h> |
|
|
36 | |
|
|
37 | #if DB_VERSION_MAJOR != 4 || (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 3) |
|
|
38 | # error you need Berkeley DB 4.3 or a newer 4.x version installed |
|
|
39 | #endif |
29 | |
40 | |
30 | /* number of seconds after which idle threads exit */ |
41 | /* number of seconds after which idle threads exit */ |
31 | #define IDLE_TIMEOUT 10 |
42 | #define IDLE_TIMEOUT 10 |
32 | |
|
|
33 | /* wether word reads are potentially non-atomic. |
|
|
34 | * this is conservatice, likely most arches this runs |
|
|
35 | * on have atomic word read/writes. |
|
|
36 | */ |
|
|
37 | #ifndef WORDACCESS_UNSAFE |
|
|
38 | # if __i386 || __x86_64 |
|
|
39 | # define WORDACCESS_UNSAFE 0 |
|
|
40 | # else |
|
|
41 | # define WORDACCESS_UNSAFE 1 |
|
|
42 | # endif |
|
|
43 | #endif |
|
|
44 | |
43 | |
45 | typedef DB_ENV DB_ENV_ornull; |
44 | typedef DB_ENV DB_ENV_ornull; |
46 | typedef DB_TXN DB_TXN_ornull; |
45 | typedef DB_TXN DB_TXN_ornull; |
47 | typedef DBC DBC_ornull; |
46 | typedef DBC DBC_ornull; |
48 | typedef DB DB_ornull; |
47 | typedef DB DB_ornull; |
|
|
48 | |
|
|
49 | typedef DB_ENV DB_ENV_ornuked; |
|
|
50 | typedef DB_TXN DB_TXN_ornuked; |
|
|
51 | typedef DBC DBC_ornuked; |
|
|
52 | typedef DB DB_ornuked; |
|
|
53 | |
|
|
54 | #if DB_VERSION_MINOR >= 3 |
49 | typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
55 | typedef DB_SEQUENCE DB_SEQUENCE_ornull; |
|
|
56 | typedef DB_SEQUENCE DB_SEQUENCE_ornuked; |
|
|
57 | #endif |
50 | |
58 | |
51 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
59 | typedef SV SV8; /* byte-sv, used for argument-checking */ |
52 | typedef char *octetstring; |
60 | typedef char *bdb_filename; |
53 | |
61 | |
54 | static SV *prepare_cb; |
62 | static SV *prepare_cb; |
55 | |
63 | |
|
|
64 | #if DB_VERSION_MINOR >= 6 |
|
|
65 | # define c_close close |
|
|
66 | # define c_count count |
|
|
67 | # define c_del del |
|
|
68 | # define c_dup dup |
|
|
69 | # define c_get get |
|
|
70 | # define c_pget pget |
|
|
71 | # define c_put put |
|
|
72 | #endif |
|
|
73 | |
56 | static inline char * |
74 | static char * |
|
|
75 | get_bdb_filename (SV *sv) |
|
|
76 | { |
|
|
77 | if (!SvOK (sv)) |
|
|
78 | return 0; |
|
|
79 | |
|
|
80 | #if _WIN32 |
|
|
81 | /* win32 madness + win32 perl absolutely brokenness make for horrible hacks */ |
|
|
82 | { |
|
|
83 | STRLEN len; |
|
|
84 | char *src = SvPVbyte (sv, len); |
|
|
85 | SV *t1 = sv_newmortal (); |
|
|
86 | SV *t2 = sv_newmortal (); |
|
|
87 | |
|
|
88 | sv_upgrade (t1, SVt_PV); SvPOK_only (t1); SvGROW (t1, len * 16 + 1); |
|
|
89 | sv_upgrade (t2, SVt_PV); SvPOK_only (t2); SvGROW (t2, len * 16 + 1); |
|
|
90 | |
|
|
91 | len = MultiByteToWideChar (CP_ACP, 0, src, len, (WCHAR *)SvPVX (t1), SvLEN (t1) / sizeof (WCHAR)); |
|
|
92 | len = WideCharToMultiByte (CP_UTF8, 0, (WCHAR *)SvPVX (t1), len, SvPVX (t2), SvLEN (t2), 0, 0); |
|
|
93 | SvPOK_only (t2); |
|
|
94 | SvPVX (t2)[len] = 0; |
|
|
95 | SvCUR_set (t2, len); |
|
|
96 | |
|
|
97 | return SvPVX (t2); |
|
|
98 | } |
|
|
99 | #else |
|
|
100 | return SvPVbyte_nolen (sv); |
|
|
101 | #endif |
|
|
102 | } |
|
|
103 | |
|
|
104 | static void |
|
|
105 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
|
|
106 | { |
|
|
107 | printf ("err[%s]\n", msg); |
|
|
108 | } |
|
|
109 | |
|
|
110 | static void |
|
|
111 | debug_msgcall (const DB_ENV *dbenv, const char *msg) |
|
|
112 | { |
|
|
113 | printf ("msg[%s]\n", msg); |
|
|
114 | } |
|
|
115 | |
|
|
116 | static char * |
57 | strdup_ornull (const char *s) |
117 | strdup_ornull (const char *s) |
58 | { |
118 | { |
59 | return s ? strdup (s) : 0; |
119 | return s ? strdup (s) : 0; |
60 | } |
120 | } |
61 | |
121 | |
62 | static inline void |
122 | static void |
63 | sv_to_dbt (DBT *dbt, SV *sv) |
123 | sv_to_dbt (DBT *dbt, SV *sv) |
64 | { |
124 | { |
65 | STRLEN len; |
125 | STRLEN len; |
66 | char *data = SvPVbyte (sv, len); |
126 | char *data = SvPVbyte (sv, len); |
67 | |
127 | |
… | |
… | |
69 | memcpy (dbt->data, data, len); |
129 | memcpy (dbt->data, data, len); |
70 | dbt->size = len; |
130 | dbt->size = len; |
71 | dbt->flags = DB_DBT_REALLOC; |
131 | dbt->flags = DB_DBT_REALLOC; |
72 | } |
132 | } |
73 | |
133 | |
74 | static inline void |
134 | static void |
75 | dbt_to_sv (SV *sv, DBT *dbt) |
135 | dbt_to_sv (SV *sv, DBT *dbt) |
76 | { |
136 | { |
77 | if (sv) |
137 | if (sv) |
78 | { |
138 | { |
79 | SvREADONLY_off (sv); |
139 | SvREADONLY_off (sv); |
80 | sv_setpvn_mg (sv, dbt->data, dbt->size); |
140 | sv_setsv_mg (sv, dbt->data ? newSVpvn (dbt->data, dbt->size) : &PL_sv_undef); |
81 | SvREFCNT_dec (sv); |
141 | SvREFCNT_dec (sv); |
82 | } |
142 | } |
83 | |
143 | |
|
|
144 | //assert (dbt->flags & DBT_MALLOC || !dbt->data); |
84 | free (dbt->data); |
145 | free (dbt->data); |
85 | } |
146 | } |
86 | |
147 | |
87 | enum { |
148 | enum { |
88 | REQ_QUIT, |
149 | REQ_QUIT, |
89 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
150 | REQ_ENV_OPEN, REQ_ENV_CLOSE, REQ_ENV_TXN_CHECKPOINT, REQ_ENV_LOCK_DETECT, |
90 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, |
151 | REQ_ENV_MEMP_SYNC, REQ_ENV_MEMP_TRICKLE, REQ_ENV_DBREMOVE, REQ_ENV_DBRENAME, |
91 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, |
152 | REQ_DB_OPEN, REQ_DB_CLOSE, REQ_DB_COMPACT, REQ_DB_SYNC, REQ_DB_UPGRADE, |
92 | REQ_DB_PUT, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
153 | REQ_DB_PUT, REQ_DB_EXISTS, REQ_DB_GET, REQ_DB_PGET, REQ_DB_DEL, REQ_DB_KEY_RANGE, |
93 | REQ_TXN_COMMIT, REQ_TXN_ABORT, |
154 | REQ_TXN_COMMIT, REQ_TXN_ABORT, REQ_TXN_FINISH, |
94 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
155 | REQ_C_CLOSE, REQ_C_COUNT, REQ_C_PUT, REQ_C_GET, REQ_C_PGET, REQ_C_DEL, |
95 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
156 | REQ_SEQ_OPEN, REQ_SEQ_CLOSE, REQ_SEQ_GET, REQ_SEQ_REMOVE, |
96 | }; |
157 | }; |
97 | |
158 | |
98 | typedef struct aio_cb |
159 | typedef struct bdb_cb |
99 | { |
160 | { |
100 | struct aio_cb *volatile next; |
161 | struct bdb_cb *volatile next; |
101 | SV *callback; |
162 | SV *callback; |
102 | int type, pri, result; |
163 | int type, pri, result; |
103 | |
164 | |
104 | DB_ENV *env; |
165 | DB_ENV *env; |
105 | DB *db; |
166 | DB *db; |
… | |
… | |
107 | DBC *dbc; |
168 | DBC *dbc; |
108 | |
169 | |
109 | UV uv1; |
170 | UV uv1; |
110 | int int1, int2; |
171 | int int1, int2; |
111 | U32 uint1, uint2; |
172 | U32 uint1, uint2; |
112 | char *buf1, *buf2; |
173 | char *buf1, *buf2, *buf3; |
113 | SV *sv1, *sv2, *sv3; |
174 | SV *sv1, *sv2, *sv3; |
114 | |
175 | |
115 | DBT dbt1, dbt2, dbt3; |
176 | DBT dbt1, dbt2, dbt3; |
116 | DB_KEY_RANGE key_range; |
177 | DB_KEY_RANGE key_range; |
|
|
178 | #if DB_VERSION_MINOR >= 3 |
117 | DB_SEQUENCE *seq; |
179 | DB_SEQUENCE *seq; |
118 | db_seq_t seq_t; |
180 | db_seq_t seq_t; |
119 | } aio_cb; |
181 | #endif |
|
|
182 | } bdb_cb; |
120 | |
183 | |
121 | typedef aio_cb *aio_req; |
184 | typedef bdb_cb *bdb_req; |
122 | |
185 | |
123 | enum { |
186 | enum { |
124 | PRI_MIN = -4, |
187 | PRI_MIN = -4, |
125 | PRI_MAX = 4, |
188 | PRI_MAX = 4, |
126 | |
189 | |
… | |
… | |
129 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
192 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
130 | }; |
193 | }; |
131 | |
194 | |
132 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
195 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
133 | |
196 | |
|
|
197 | static SV *on_next_submit; |
|
|
198 | |
134 | static unsigned int max_poll_time = 0; |
199 | static unsigned int max_poll_time = 0; |
135 | static unsigned int max_poll_reqs = 0; |
200 | static unsigned int max_poll_reqs = 0; |
136 | |
201 | |
137 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
202 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
138 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
203 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
… | |
… | |
143 | |
208 | |
144 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
209 | static int next_pri = DEFAULT_PRI + PRI_BIAS; |
145 | |
210 | |
146 | static unsigned int started, idle, wanted; |
211 | static unsigned int started, idle, wanted; |
147 | |
212 | |
148 | #if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) |
|
|
149 | # define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
|
|
150 | #else |
|
|
151 | # define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER |
|
|
152 | #endif |
|
|
153 | |
|
|
154 | #define LOCK(mutex) pthread_mutex_lock (&(mutex)) |
|
|
155 | #define UNLOCK(mutex) pthread_mutex_unlock (&(mutex)) |
|
|
156 | |
|
|
157 | /* worker threads management */ |
213 | /* worker threads management */ |
158 | static pthread_mutex_t wrklock = AIO_MUTEX_INIT; |
214 | static mutex_t wrklock = X_MUTEX_INIT; |
159 | |
215 | |
160 | typedef struct worker { |
216 | typedef struct worker { |
161 | /* locked by wrklock */ |
217 | /* locked by wrklock */ |
162 | struct worker *prev, *next; |
218 | struct worker *prev, *next; |
163 | |
219 | |
164 | pthread_t tid; |
220 | thread_t tid; |
165 | |
221 | |
166 | /* locked by reslock, reqlock or wrklock */ |
222 | /* locked by reslock, reqlock or wrklock */ |
167 | aio_req req; /* currently processed request */ |
223 | bdb_req req; /* currently processed request */ |
168 | void *dbuf; |
224 | void *dbuf; |
169 | DIR *dirp; |
225 | DIR *dirp; |
170 | } worker; |
226 | } worker; |
171 | |
227 | |
172 | static worker wrk_first = { &wrk_first, &wrk_first, 0 }; |
228 | static worker wrk_first = { &wrk_first, &wrk_first, 0 }; |
… | |
… | |
184 | } |
240 | } |
185 | |
241 | |
186 | static volatile unsigned int nreqs, nready, npending; |
242 | static volatile unsigned int nreqs, nready, npending; |
187 | static volatile unsigned int max_idle = 4; |
243 | static volatile unsigned int max_idle = 4; |
188 | static volatile unsigned int max_outstanding = 0xffffffff; |
244 | static volatile unsigned int max_outstanding = 0xffffffff; |
189 | static int respipe [2]; |
245 | static int respipe_osf [2], respipe [2] = { -1, -1 }; |
190 | |
246 | |
191 | static pthread_mutex_t reslock = AIO_MUTEX_INIT; |
247 | static mutex_t reslock = X_MUTEX_INIT; |
192 | static pthread_mutex_t reqlock = AIO_MUTEX_INIT; |
248 | static mutex_t reqlock = X_MUTEX_INIT; |
193 | static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER; |
249 | static cond_t reqwait = X_COND_INIT; |
194 | |
250 | |
195 | #if WORDACCESS_UNSAFE |
251 | #if WORDACCESS_UNSAFE |
196 | |
252 | |
197 | static unsigned int get_nready () |
253 | static unsigned int get_nready (void) |
198 | { |
254 | { |
199 | unsigned int retval; |
255 | unsigned int retval; |
200 | |
256 | |
201 | LOCK (reqlock); |
257 | X_LOCK (reqlock); |
202 | retval = nready; |
258 | retval = nready; |
203 | UNLOCK (reqlock); |
259 | X_UNLOCK (reqlock); |
204 | |
260 | |
205 | return retval; |
261 | return retval; |
206 | } |
262 | } |
207 | |
263 | |
208 | static unsigned int get_npending () |
264 | static unsigned int get_npending (void) |
209 | { |
265 | { |
210 | unsigned int retval; |
266 | unsigned int retval; |
211 | |
267 | |
212 | LOCK (reslock); |
268 | X_LOCK (reslock); |
213 | retval = npending; |
269 | retval = npending; |
214 | UNLOCK (reslock); |
270 | X_UNLOCK (reslock); |
215 | |
271 | |
216 | return retval; |
272 | return retval; |
217 | } |
273 | } |
218 | |
274 | |
219 | static unsigned int get_nthreads () |
275 | static unsigned int get_nthreads (void) |
220 | { |
276 | { |
221 | unsigned int retval; |
277 | unsigned int retval; |
222 | |
278 | |
223 | LOCK (wrklock); |
279 | X_LOCK (wrklock); |
224 | retval = started; |
280 | retval = started; |
225 | UNLOCK (wrklock); |
281 | X_UNLOCK (wrklock); |
226 | |
282 | |
227 | return retval; |
283 | return retval; |
228 | } |
284 | } |
229 | |
285 | |
230 | #else |
286 | #else |
… | |
… | |
239 | * a somewhat faster data structure might be nice, but |
295 | * a somewhat faster data structure might be nice, but |
240 | * with 8 priorities this actually needs <20 insns |
296 | * with 8 priorities this actually needs <20 insns |
241 | * per shift, the most expensive operation. |
297 | * per shift, the most expensive operation. |
242 | */ |
298 | */ |
243 | typedef struct { |
299 | typedef struct { |
244 | aio_req qs[NUM_PRI], qe[NUM_PRI]; /* qstart, qend */ |
300 | bdb_req qs[NUM_PRI], qe[NUM_PRI]; /* qstart, qend */ |
245 | int size; |
301 | int size; |
246 | } reqq; |
302 | } reqq; |
247 | |
303 | |
248 | static reqq req_queue; |
304 | static reqq req_queue; |
249 | static reqq res_queue; |
305 | static reqq res_queue; |
250 | |
306 | |
251 | int reqq_push (reqq *q, aio_req req) |
307 | int reqq_push (reqq *q, bdb_req req) |
252 | { |
308 | { |
253 | int pri = req->pri; |
309 | int pri = req->pri; |
254 | req->next = 0; |
310 | req->next = 0; |
255 | |
311 | |
256 | if (q->qe[pri]) |
312 | if (q->qe[pri]) |
… | |
… | |
262 | q->qe[pri] = q->qs[pri] = req; |
318 | q->qe[pri] = q->qs[pri] = req; |
263 | |
319 | |
264 | return q->size++; |
320 | return q->size++; |
265 | } |
321 | } |
266 | |
322 | |
267 | aio_req reqq_shift (reqq *q) |
323 | bdb_req reqq_shift (reqq *q) |
268 | { |
324 | { |
269 | int pri; |
325 | int pri; |
270 | |
326 | |
271 | if (!q->size) |
327 | if (!q->size) |
272 | return 0; |
328 | return 0; |
273 | |
329 | |
274 | --q->size; |
330 | --q->size; |
275 | |
331 | |
276 | for (pri = NUM_PRI; pri--; ) |
332 | for (pri = NUM_PRI; pri--; ) |
277 | { |
333 | { |
278 | aio_req req = q->qs[pri]; |
334 | bdb_req req = q->qs[pri]; |
279 | |
335 | |
280 | if (req) |
336 | if (req) |
281 | { |
337 | { |
282 | if (!(q->qs[pri] = req->next)) |
338 | if (!(q->qs[pri] = req->next)) |
283 | q->qe[pri] = 0; |
339 | q->qe[pri] = 0; |
… | |
… | |
287 | } |
343 | } |
288 | |
344 | |
289 | abort (); |
345 | abort (); |
290 | } |
346 | } |
291 | |
347 | |
292 | static int poll_cb (); |
348 | static int poll_cb (void); |
293 | static void req_free (aio_req req); |
349 | static void req_free (bdb_req req); |
294 | static void req_cancel (aio_req req); |
350 | static void req_cancel (bdb_req req); |
295 | |
351 | |
296 | static int req_invoke (aio_req req) |
352 | static int req_invoke (bdb_req req) |
297 | { |
353 | { |
298 | dSP; |
354 | dSP; |
299 | |
355 | |
300 | if (SvOK (req->callback)) |
356 | if (req->callback) |
301 | { |
357 | { |
302 | ENTER; |
358 | ENTER; |
303 | SAVETMPS; |
359 | SAVETMPS; |
304 | PUSHMARK (SP); |
360 | PUSHMARK (SP); |
305 | |
361 | |
… | |
… | |
319 | dbt_to_sv (req->sv1, &req->dbt1); |
375 | dbt_to_sv (req->sv1, &req->dbt1); |
320 | dbt_to_sv (req->sv2, &req->dbt2); |
376 | dbt_to_sv (req->sv2, &req->dbt2); |
321 | dbt_to_sv (req->sv3, &req->dbt3); |
377 | dbt_to_sv (req->sv3, &req->dbt3); |
322 | break; |
378 | break; |
323 | |
379 | |
|
|
380 | case REQ_DB_PUT: |
|
|
381 | case REQ_C_PUT: |
|
|
382 | dbt_to_sv (0, &req->dbt1); |
|
|
383 | dbt_to_sv (0, &req->dbt2); |
|
|
384 | break; |
|
|
385 | |
324 | case REQ_DB_KEY_RANGE: |
386 | case REQ_DB_KEY_RANGE: |
325 | { |
387 | { |
326 | AV *av = newAV (); |
388 | AV *av = newAV (); |
327 | |
389 | |
328 | av_push (av, newSVnv (req->key_range.less)); |
390 | av_push (av, newSVnv (req->key_range.less)); |
… | |
… | |
333 | sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av)); |
395 | sv_setsv_mg (req->sv1, newRV_noinc ((SV *)av)); |
334 | SvREFCNT_dec (req->sv1); |
396 | SvREFCNT_dec (req->sv1); |
335 | } |
397 | } |
336 | break; |
398 | break; |
337 | |
399 | |
|
|
400 | #if DB_VERSION_MINOR >= 3 |
338 | case REQ_SEQ_GET: |
401 | case REQ_SEQ_GET: |
339 | SvREADONLY_off (req->sv1); |
402 | SvREADONLY_off (req->sv1); |
340 | |
403 | |
341 | if (sizeof (IV) > 4) |
404 | if (sizeof (IV) > 4) |
342 | sv_setiv_mg (req->sv1, req->seq_t); |
405 | sv_setiv_mg (req->sv1, (IV)req->seq_t); |
343 | else |
406 | else |
344 | sv_setnv_mg (req->sv1, req->seq_t); |
407 | sv_setnv_mg (req->sv1, (NV)req->seq_t); |
345 | |
408 | |
346 | SvREFCNT_dec (req->sv1); |
409 | SvREFCNT_dec (req->sv1); |
347 | break; |
410 | break; |
|
|
411 | #endif |
348 | } |
412 | } |
349 | |
413 | |
350 | errno = req->result; |
414 | errno = req->result; |
351 | |
415 | |
352 | PUTBACK; |
416 | PUTBACK; |
… | |
… | |
358 | } |
422 | } |
359 | |
423 | |
360 | return !SvTRUE (ERRSV); |
424 | return !SvTRUE (ERRSV); |
361 | } |
425 | } |
362 | |
426 | |
363 | static void req_free (aio_req req) |
427 | static void req_free (bdb_req req) |
364 | { |
428 | { |
|
|
429 | SvREFCNT_dec (req->callback); |
|
|
430 | |
365 | free (req->buf1); |
431 | free (req->buf1); |
366 | free (req->buf2); |
432 | free (req->buf2); |
|
|
433 | free (req->buf3); |
|
|
434 | |
367 | Safefree (req); |
435 | Safefree (req); |
368 | } |
436 | } |
369 | |
437 | |
370 | static void *aio_proc (void *arg); |
438 | #ifdef USE_SOCKETS_AS_HANDLES |
|
|
439 | # define TO_SOCKET(x) (win32_get_osfhandle (x)) |
|
|
440 | #else |
|
|
441 | # define TO_SOCKET(x) (x) |
|
|
442 | #endif |
|
|
443 | |
|
|
444 | static void |
|
|
445 | create_respipe (void) |
|
|
446 | { |
|
|
447 | #ifdef _WIN32 |
|
|
448 | int arg; /* argg */ |
|
|
449 | #endif |
|
|
450 | int old_readfd = respipe [0]; |
|
|
451 | |
|
|
452 | if (respipe [1] >= 0) |
|
|
453 | respipe_close (TO_SOCKET (respipe [1])); |
|
|
454 | |
|
|
455 | #ifdef _WIN32 |
|
|
456 | if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, respipe)) |
|
|
457 | #else |
|
|
458 | if (pipe (respipe)) |
|
|
459 | #endif |
|
|
460 | croak ("unable to initialize result pipe"); |
|
|
461 | |
|
|
462 | if (old_readfd >= 0) |
|
|
463 | { |
|
|
464 | if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0) |
|
|
465 | croak ("unable to initialize result pipe(2)"); |
|
|
466 | |
|
|
467 | respipe_close (respipe [0]); |
|
|
468 | respipe [0] = old_readfd; |
|
|
469 | } |
|
|
470 | |
|
|
471 | #ifdef _WIN32 |
|
|
472 | arg = 1; |
|
|
473 | if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg) |
|
|
474 | || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg)) |
|
|
475 | #else |
|
|
476 | if (fcntl (respipe [0], F_SETFL, O_NONBLOCK) |
|
|
477 | || fcntl (respipe [1], F_SETFL, O_NONBLOCK)) |
|
|
478 | #endif |
|
|
479 | croak ("unable to initialize result pipe(3)"); |
|
|
480 | |
|
|
481 | respipe_osf [0] = TO_SOCKET (respipe [0]); |
|
|
482 | respipe_osf [1] = TO_SOCKET (respipe [1]); |
|
|
483 | } |
|
|
484 | |
|
|
485 | X_THREAD_PROC (bdb_proc); |
371 | |
486 | |
372 | static void start_thread (void) |
487 | static void start_thread (void) |
373 | { |
488 | { |
374 | sigset_t fullsigset, oldsigset; |
|
|
375 | pthread_attr_t attr; |
|
|
376 | |
|
|
377 | worker *wrk = calloc (1, sizeof (worker)); |
489 | worker *wrk = calloc (1, sizeof (worker)); |
378 | |
490 | |
379 | if (!wrk) |
491 | if (!wrk) |
380 | croak ("unable to allocate worker thread data"); |
492 | croak ("unable to allocate worker thread data"); |
381 | |
493 | |
382 | pthread_attr_init (&attr); |
|
|
383 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); |
|
|
384 | #ifdef PTHREAD_SCOPE_PROCESS |
|
|
385 | pthread_attr_setscope (&attr, PTHREAD_SCOPE_PROCESS); |
|
|
386 | #endif |
|
|
387 | |
|
|
388 | sigfillset (&fullsigset); |
|
|
389 | |
|
|
390 | LOCK (wrklock); |
494 | X_LOCK (wrklock); |
391 | pthread_sigmask (SIG_SETMASK, &fullsigset, &oldsigset); |
|
|
392 | |
|
|
393 | if (pthread_create (&wrk->tid, &attr, aio_proc, (void *)wrk) == 0) |
495 | if (thread_create (&wrk->tid, bdb_proc, (void *)wrk)) |
394 | { |
496 | { |
395 | wrk->prev = &wrk_first; |
497 | wrk->prev = &wrk_first; |
396 | wrk->next = wrk_first.next; |
498 | wrk->next = wrk_first.next; |
397 | wrk_first.next->prev = wrk; |
499 | wrk_first.next->prev = wrk; |
398 | wrk_first.next = wrk; |
500 | wrk_first.next = wrk; |
399 | ++started; |
501 | ++started; |
400 | } |
502 | } |
401 | else |
503 | else |
402 | free (wrk); |
504 | free (wrk); |
403 | |
505 | |
404 | pthread_sigmask (SIG_SETMASK, &oldsigset, 0); |
|
|
405 | UNLOCK (wrklock); |
506 | X_UNLOCK (wrklock); |
406 | } |
507 | } |
407 | |
508 | |
408 | static void maybe_start_thread () |
509 | static void maybe_start_thread (void) |
409 | { |
510 | { |
410 | if (get_nthreads () >= wanted) |
511 | if (get_nthreads () >= wanted) |
411 | return; |
512 | return; |
412 | |
513 | |
413 | /* todo: maybe use idle here, but might be less exact */ |
514 | /* todo: maybe use idle here, but might be less exact */ |
… | |
… | |
415 | return; |
516 | return; |
416 | |
517 | |
417 | start_thread (); |
518 | start_thread (); |
418 | } |
519 | } |
419 | |
520 | |
420 | static void req_send (aio_req req) |
521 | static void req_send (bdb_req req) |
421 | { |
522 | { |
422 | SV *wait_callback = 0; |
523 | SV *wait_callback = 0; |
423 | |
524 | |
|
|
525 | if (on_next_submit) |
|
|
526 | { |
|
|
527 | dSP; |
|
|
528 | SV *cb = sv_2mortal (on_next_submit); |
|
|
529 | |
|
|
530 | on_next_submit = 0; |
|
|
531 | |
|
|
532 | PUSHMARK (SP); |
|
|
533 | PUTBACK; |
|
|
534 | call_sv (cb, G_DISCARD | G_EVAL); |
|
|
535 | SPAGAIN; |
|
|
536 | } |
|
|
537 | |
424 | // synthesize callback if none given |
538 | // synthesize callback if none given |
425 | if (!SvOK (req->callback)) |
539 | if (!req->callback) |
426 | { |
540 | { |
|
|
541 | int count; |
|
|
542 | |
427 | dSP; |
543 | dSP; |
428 | PUSHMARK (SP); |
544 | PUSHMARK (SP); |
429 | PUTBACK; |
545 | PUTBACK; |
430 | int count = call_sv (prepare_cb, G_ARRAY); |
546 | count = call_sv (prepare_cb, G_ARRAY); |
431 | SPAGAIN; |
547 | SPAGAIN; |
432 | |
548 | |
433 | if (count != 2) |
549 | if (count != 2) |
434 | croak ("prepare callback must return exactly two values\n"); |
550 | croak ("prepare callback must return exactly two values\n"); |
435 | |
551 | |
436 | wait_callback = SvREFCNT_inc (POPs); |
552 | wait_callback = POPs; |
437 | SvREFCNT_dec (req->callback); |
|
|
438 | req->callback = SvREFCNT_inc (POPs); |
553 | req->callback = SvREFCNT_inc (POPs); |
439 | } |
554 | } |
440 | |
555 | |
441 | ++nreqs; |
556 | ++nreqs; |
442 | |
557 | |
443 | LOCK (reqlock); |
558 | X_LOCK (reqlock); |
444 | ++nready; |
559 | ++nready; |
445 | reqq_push (&req_queue, req); |
560 | reqq_push (&req_queue, req); |
446 | pthread_cond_signal (&reqwait); |
561 | X_COND_SIGNAL (reqwait); |
447 | UNLOCK (reqlock); |
562 | X_UNLOCK (reqlock); |
448 | |
563 | |
449 | maybe_start_thread (); |
564 | maybe_start_thread (); |
450 | |
565 | |
451 | if (wait_callback) |
566 | if (wait_callback) |
452 | { |
567 | { |
453 | dSP; |
568 | dSP; |
454 | PUSHMARK (SP); |
569 | PUSHMARK (SP); |
455 | PUTBACK; |
570 | PUTBACK; |
456 | call_sv (wait_callback, G_DISCARD); |
571 | call_sv (wait_callback, G_DISCARD); |
457 | SvREFCNT_dec (wait_callback); |
|
|
458 | } |
572 | } |
459 | } |
573 | } |
460 | |
574 | |
461 | static void end_thread (void) |
575 | static void end_thread (void) |
462 | { |
576 | { |
463 | aio_req req; |
577 | bdb_req req; |
464 | |
578 | |
465 | Newz (0, req, 1, aio_cb); |
579 | Newz (0, req, 1, bdb_cb); |
466 | |
580 | |
467 | req->type = REQ_QUIT; |
581 | req->type = REQ_QUIT; |
468 | req->pri = PRI_MAX + PRI_BIAS; |
582 | req->pri = PRI_MAX + PRI_BIAS; |
469 | |
583 | |
470 | LOCK (reqlock); |
584 | X_LOCK (reqlock); |
471 | reqq_push (&req_queue, req); |
585 | reqq_push (&req_queue, req); |
472 | pthread_cond_signal (&reqwait); |
586 | X_COND_SIGNAL (reqwait); |
473 | UNLOCK (reqlock); |
587 | X_UNLOCK (reqlock); |
474 | |
588 | |
475 | LOCK (wrklock); |
589 | X_LOCK (wrklock); |
476 | --started; |
590 | --started; |
477 | UNLOCK (wrklock); |
591 | X_UNLOCK (wrklock); |
478 | } |
592 | } |
479 | |
593 | |
480 | static void set_max_idle (int nthreads) |
594 | static void set_max_idle (int nthreads) |
481 | { |
595 | { |
482 | if (WORDACCESS_UNSAFE) LOCK (reqlock); |
596 | if (WORDACCESS_UNSAFE) X_LOCK (reqlock); |
483 | max_idle = nthreads <= 0 ? 1 : nthreads; |
597 | max_idle = nthreads <= 0 ? 1 : nthreads; |
484 | if (WORDACCESS_UNSAFE) UNLOCK (reqlock); |
598 | if (WORDACCESS_UNSAFE) X_UNLOCK (reqlock); |
485 | } |
599 | } |
486 | |
600 | |
487 | static void min_parallel (int nthreads) |
601 | static void min_parallel (int nthreads) |
488 | { |
602 | { |
489 | if (wanted < nthreads) |
603 | if (wanted < nthreads) |
… | |
… | |
497 | |
611 | |
498 | while (started > wanted) |
612 | while (started > wanted) |
499 | end_thread (); |
613 | end_thread (); |
500 | } |
614 | } |
501 | |
615 | |
502 | static void poll_wait () |
616 | static void poll_wait (void) |
503 | { |
617 | { |
504 | fd_set rfd; |
618 | fd_set rfd; |
505 | |
619 | |
506 | while (nreqs) |
620 | while (nreqs) |
507 | { |
621 | { |
508 | int size; |
622 | int size; |
509 | if (WORDACCESS_UNSAFE) LOCK (reslock); |
623 | if (WORDACCESS_UNSAFE) X_LOCK (reslock); |
510 | size = res_queue.size; |
624 | size = res_queue.size; |
511 | if (WORDACCESS_UNSAFE) UNLOCK (reslock); |
625 | if (WORDACCESS_UNSAFE) X_UNLOCK (reslock); |
512 | |
626 | |
513 | if (size) |
627 | if (size) |
514 | return; |
628 | return; |
515 | |
629 | |
516 | maybe_start_thread (); |
630 | maybe_start_thread (); |
517 | |
631 | |
518 | FD_ZERO(&rfd); |
632 | FD_ZERO (&rfd); |
519 | FD_SET(respipe [0], &rfd); |
633 | FD_SET (respipe [0], &rfd); |
520 | |
634 | |
521 | select (respipe [0] + 1, &rfd, 0, 0, 0); |
635 | PerlSock_select (respipe [0] + 1, &rfd, 0, 0, 0); |
522 | } |
636 | } |
523 | } |
637 | } |
524 | |
638 | |
525 | static int poll_cb () |
639 | static int poll_cb (void) |
526 | { |
640 | { |
527 | dSP; |
641 | dSP; |
528 | int count = 0; |
642 | int count = 0; |
529 | int maxreqs = max_poll_reqs; |
643 | int maxreqs = max_poll_reqs; |
530 | int do_croak = 0; |
644 | int do_croak = 0; |
531 | struct timeval tv_start, tv_now; |
645 | struct timeval tv_start, tv_now; |
532 | aio_req req; |
646 | bdb_req req; |
533 | |
647 | |
534 | if (max_poll_time) |
648 | if (max_poll_time) |
535 | gettimeofday (&tv_start, 0); |
649 | gettimeofday (&tv_start, 0); |
536 | |
650 | |
537 | for (;;) |
651 | for (;;) |
538 | { |
652 | { |
539 | for (;;) |
653 | for (;;) |
540 | { |
654 | { |
541 | maybe_start_thread (); |
655 | maybe_start_thread (); |
542 | |
656 | |
543 | LOCK (reslock); |
657 | X_LOCK (reslock); |
544 | req = reqq_shift (&res_queue); |
658 | req = reqq_shift (&res_queue); |
545 | |
659 | |
546 | if (req) |
660 | if (req) |
547 | { |
661 | { |
548 | --npending; |
662 | --npending; |
549 | |
663 | |
550 | if (!res_queue.size) |
664 | if (!res_queue.size) |
551 | { |
665 | { |
552 | /* read any signals sent by the worker threads */ |
666 | /* read any signals sent by the worker threads */ |
553 | char buf [4]; |
667 | char buf [4]; |
554 | while (read (respipe [0], buf, 4) == 4) |
668 | while (respipe_read (respipe [0], buf, 4) == 4) |
555 | ; |
669 | ; |
556 | } |
670 | } |
557 | } |
671 | } |
558 | |
672 | |
559 | UNLOCK (reslock); |
673 | X_UNLOCK (reslock); |
560 | |
674 | |
561 | if (!req) |
675 | if (!req) |
562 | break; |
676 | break; |
563 | |
677 | |
564 | --nreqs; |
678 | --nreqs; |
… | |
… | |
594 | } |
708 | } |
595 | |
709 | |
596 | return count; |
710 | return count; |
597 | } |
711 | } |
598 | |
712 | |
599 | static void create_pipe () |
|
|
600 | { |
|
|
601 | if (pipe (respipe)) |
|
|
602 | croak ("unable to initialize result pipe"); |
|
|
603 | |
|
|
604 | if (fcntl (respipe [0], F_SETFL, O_NONBLOCK)) |
|
|
605 | croak ("cannot set result pipe to nonblocking mode"); |
|
|
606 | |
|
|
607 | if (fcntl (respipe [1], F_SETFL, O_NONBLOCK)) |
|
|
608 | croak ("cannot set result pipe to nonblocking mode"); |
|
|
609 | } |
|
|
610 | |
|
|
611 | /*****************************************************************************/ |
713 | /*****************************************************************************/ |
612 | |
714 | |
613 | static void *aio_proc (void *thr_arg) |
715 | X_THREAD_PROC (bdb_proc) |
614 | { |
716 | { |
615 | aio_req req; |
717 | bdb_req req; |
616 | struct timespec ts; |
718 | struct timespec ts; |
617 | worker *self = (worker *)thr_arg; |
719 | worker *self = (worker *)thr_arg; |
618 | |
720 | |
619 | /* try to distribute timeouts somewhat evenly */ |
721 | /* try to distribute timeouts somewhat evenly */ |
620 | ts.tv_nsec = (((unsigned long)self + (unsigned long)ts.tv_sec) & 1023UL) |
722 | ts.tv_nsec = ((unsigned long)self & 1023UL) * (1000000000UL / 1024UL); |
621 | * (1000000000UL / 1024UL); |
|
|
622 | |
723 | |
623 | for (;;) |
724 | for (;;) |
624 | { |
725 | { |
625 | ts.tv_sec = time (0) + IDLE_TIMEOUT; |
726 | ts.tv_sec = time (0) + IDLE_TIMEOUT; |
626 | |
727 | |
627 | LOCK (reqlock); |
728 | X_LOCK (reqlock); |
628 | |
729 | |
629 | for (;;) |
730 | for (;;) |
630 | { |
731 | { |
631 | self->req = req = reqq_shift (&req_queue); |
732 | self->req = req = reqq_shift (&req_queue); |
632 | |
733 | |
633 | if (req) |
734 | if (req) |
634 | break; |
735 | break; |
635 | |
736 | |
636 | ++idle; |
737 | ++idle; |
637 | |
738 | |
638 | if (pthread_cond_timedwait (&reqwait, &reqlock, &ts) |
739 | if (X_COND_TIMEDWAIT (reqwait, reqlock, ts) |
639 | == ETIMEDOUT) |
740 | == ETIMEDOUT) |
640 | { |
741 | { |
641 | if (idle > max_idle) |
742 | if (idle > max_idle) |
642 | { |
743 | { |
643 | --idle; |
744 | --idle; |
644 | UNLOCK (reqlock); |
745 | X_UNLOCK (reqlock); |
645 | LOCK (wrklock); |
746 | X_LOCK (wrklock); |
646 | --started; |
747 | --started; |
647 | UNLOCK (wrklock); |
748 | X_UNLOCK (wrklock); |
648 | goto quit; |
749 | goto quit; |
649 | } |
750 | } |
650 | |
751 | |
651 | /* we are allowed to idle, so do so without any timeout */ |
752 | /* we are allowed to idle, so do so without any timeout */ |
652 | pthread_cond_wait (&reqwait, &reqlock); |
753 | X_COND_WAIT (reqwait, reqlock); |
653 | ts.tv_sec = time (0) + IDLE_TIMEOUT; |
754 | ts.tv_sec = time (0) + IDLE_TIMEOUT; |
654 | } |
755 | } |
655 | |
756 | |
656 | --idle; |
757 | --idle; |
657 | } |
758 | } |
658 | |
759 | |
659 | --nready; |
760 | --nready; |
660 | |
761 | |
661 | UNLOCK (reqlock); |
762 | X_UNLOCK (reqlock); |
662 | |
763 | |
663 | switch (req->type) |
764 | switch (req->type) |
664 | { |
765 | { |
665 | case REQ_QUIT: |
766 | case REQ_QUIT: |
|
|
767 | req->result = ENOSYS; |
666 | goto quit; |
768 | goto quit; |
667 | |
769 | |
668 | case REQ_ENV_OPEN: |
770 | case REQ_ENV_OPEN: |
669 | req->result = req->env->open (req->env, req->buf1, req->uint1, req->int1); |
771 | req->result = req->env->open (req->env, req->buf1, req->uint1, req->int1); |
670 | break; |
772 | break; |
… | |
… | |
687 | |
789 | |
688 | case REQ_ENV_MEMP_TRICKLE: |
790 | case REQ_ENV_MEMP_TRICKLE: |
689 | req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
791 | req->result = req->env->memp_trickle (req->env, req->int1, &req->int2); |
690 | break; |
792 | break; |
691 | |
793 | |
|
|
794 | case REQ_ENV_DBREMOVE: |
|
|
795 | req->result = req->env->dbremove (req->env, req->txn, req->buf1, req->buf2, req->uint1); |
|
|
796 | break; |
|
|
797 | |
|
|
798 | case REQ_ENV_DBRENAME: |
|
|
799 | req->result = req->env->dbrename (req->env, req->txn, req->buf1, req->buf2, req->buf3, req->uint1); |
|
|
800 | break; |
|
|
801 | |
692 | case REQ_DB_OPEN: |
802 | case REQ_DB_OPEN: |
693 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
803 | req->result = req->db->open (req->db, req->txn, req->buf1, req->buf2, req->int1, req->uint1, req->int2); |
694 | break; |
804 | break; |
695 | |
805 | |
696 | case REQ_DB_CLOSE: |
806 | case REQ_DB_CLOSE: |
697 | req->result = req->db->close (req->db, req->uint1); |
807 | req->result = req->db->close (req->db, req->uint1); |
698 | break; |
808 | break; |
699 | |
809 | |
|
|
810 | #if DB_VERSION_MINOR >= 4 |
700 | case REQ_DB_COMPACT: |
811 | case REQ_DB_COMPACT: |
701 | req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0); |
812 | req->result = req->db->compact (req->db, req->txn, &req->dbt1, &req->dbt2, 0, req->uint1, 0); |
702 | break; |
813 | break; |
|
|
814 | #endif |
703 | |
815 | |
704 | case REQ_DB_SYNC: |
816 | case REQ_DB_SYNC: |
705 | req->result = req->db->sync (req->db, req->uint1); |
817 | req->result = req->db->sync (req->db, req->uint1); |
706 | break; |
818 | break; |
707 | |
819 | |
|
|
820 | case REQ_DB_UPGRADE: |
|
|
821 | req->result = req->db->upgrade (req->db, req->buf1, req->uint1); |
|
|
822 | break; |
|
|
823 | |
708 | case REQ_DB_PUT: |
824 | case REQ_DB_PUT: |
709 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
825 | req->result = req->db->put (req->db, req->txn, &req->dbt1, &req->dbt2, req->uint1); |
710 | break; |
826 | break; |
711 | |
827 | |
|
|
828 | #if DB_VERSION_MINOR >= 6 |
|
|
829 | case REQ_DB_EXISTS: |
|
|
830 | req->result = req->db->exists (req->db, req->txn, &req->dbt1, req->uint1); |
|
|
831 | break; |
|
|
832 | #endif |
712 | case REQ_DB_GET: |
833 | case REQ_DB_GET: |
713 | req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1); |
834 | req->result = req->db->get (req->db, req->txn, &req->dbt1, &req->dbt3, req->uint1); |
714 | break; |
835 | break; |
715 | |
836 | |
716 | case REQ_DB_PGET: |
837 | case REQ_DB_PGET: |
… | |
… | |
729 | req->result = req->txn->commit (req->txn, req->uint1); |
850 | req->result = req->txn->commit (req->txn, req->uint1); |
730 | break; |
851 | break; |
731 | |
852 | |
732 | case REQ_TXN_ABORT: |
853 | case REQ_TXN_ABORT: |
733 | req->result = req->txn->abort (req->txn); |
854 | req->result = req->txn->abort (req->txn); |
|
|
855 | break; |
|
|
856 | |
|
|
857 | case REQ_TXN_FINISH: |
|
|
858 | if (req->txn->flags & TXN_DEADLOCK) |
|
|
859 | { |
|
|
860 | req->result = req->txn->abort (req->txn); |
|
|
861 | if (!req->result) |
|
|
862 | req->result = DB_LOCK_DEADLOCK; |
|
|
863 | } |
|
|
864 | else |
|
|
865 | req->result = req->txn->commit (req->txn, req->uint1); |
734 | break; |
866 | break; |
735 | |
867 | |
736 | case REQ_C_CLOSE: |
868 | case REQ_C_CLOSE: |
737 | req->result = req->dbc->c_close (req->dbc); |
869 | req->result = req->dbc->c_close (req->dbc); |
738 | break; |
870 | break; |
… | |
… | |
759 | |
891 | |
760 | case REQ_C_DEL: |
892 | case REQ_C_DEL: |
761 | req->result = req->dbc->c_del (req->dbc, req->uint1); |
893 | req->result = req->dbc->c_del (req->dbc, req->uint1); |
762 | break; |
894 | break; |
763 | |
895 | |
|
|
896 | #if DB_VERSION_MINOR >= 3 |
764 | case REQ_SEQ_OPEN: |
897 | case REQ_SEQ_OPEN: |
765 | req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
898 | req->result = req->seq->open (req->seq, req->txn, &req->dbt1, req->uint1); |
766 | break; |
899 | break; |
767 | |
900 | |
768 | case REQ_SEQ_CLOSE: |
901 | case REQ_SEQ_CLOSE: |
… | |
… | |
774 | break; |
907 | break; |
775 | |
908 | |
776 | case REQ_SEQ_REMOVE: |
909 | case REQ_SEQ_REMOVE: |
777 | req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
910 | req->result = req->seq->remove (req->seq, req->txn, req->uint1); |
778 | break; |
911 | break; |
|
|
912 | #endif |
779 | |
913 | |
780 | default: |
914 | default: |
781 | req->result = ENOSYS; |
915 | req->result = ENOSYS; |
782 | break; |
916 | break; |
783 | } |
917 | } |
784 | |
918 | |
|
|
919 | if (req->txn && (req->result > 0 || req->result == DB_LOCK_NOTGRANTED)) |
|
|
920 | req->txn->flags |= TXN_DEADLOCK; |
|
|
921 | |
785 | LOCK (reslock); |
922 | X_LOCK (reslock); |
786 | |
923 | |
787 | ++npending; |
924 | ++npending; |
788 | |
925 | |
789 | if (!reqq_push (&res_queue, req)) |
926 | if (!reqq_push (&res_queue, req)) |
790 | /* write a dummy byte to the pipe so fh becomes ready */ |
927 | /* write a dummy byte to the pipe so fh becomes ready */ |
791 | write (respipe [1], &respipe, 1); |
928 | respipe_write (respipe_osf [1], (const void *)&respipe_osf, 1); |
792 | |
929 | |
793 | self->req = 0; |
930 | self->req = 0; |
794 | worker_clear (self); |
931 | worker_clear (self); |
795 | |
932 | |
796 | UNLOCK (reslock); |
933 | X_UNLOCK (reslock); |
797 | } |
934 | } |
798 | |
935 | |
799 | quit: |
936 | quit: |
800 | LOCK (wrklock); |
937 | X_LOCK (wrklock); |
801 | worker_free (self); |
938 | worker_free (self); |
802 | UNLOCK (wrklock); |
939 | X_UNLOCK (wrklock); |
803 | |
940 | |
804 | return 0; |
941 | return 0; |
805 | } |
942 | } |
806 | |
943 | |
807 | /*****************************************************************************/ |
944 | /*****************************************************************************/ |
808 | |
945 | |
809 | static void atfork_prepare (void) |
946 | static void atfork_prepare (void) |
810 | { |
947 | { |
811 | LOCK (wrklock); |
948 | X_LOCK (wrklock); |
812 | LOCK (reqlock); |
949 | X_LOCK (reqlock); |
813 | LOCK (reslock); |
950 | X_LOCK (reslock); |
814 | } |
951 | } |
815 | |
952 | |
816 | static void atfork_parent (void) |
953 | static void atfork_parent (void) |
817 | { |
954 | { |
818 | UNLOCK (reslock); |
955 | X_UNLOCK (reslock); |
819 | UNLOCK (reqlock); |
956 | X_UNLOCK (reqlock); |
820 | UNLOCK (wrklock); |
957 | X_UNLOCK (wrklock); |
821 | } |
958 | } |
822 | |
959 | |
823 | static void atfork_child (void) |
960 | static void atfork_child (void) |
824 | { |
961 | { |
825 | aio_req prv; |
962 | bdb_req prv; |
826 | |
963 | |
827 | while (prv = reqq_shift (&req_queue)) |
964 | while (prv = reqq_shift (&req_queue)) |
828 | req_free (prv); |
965 | req_free (prv); |
829 | |
966 | |
830 | while (prv = reqq_shift (&res_queue)) |
967 | while (prv = reqq_shift (&res_queue)) |
… | |
… | |
845 | idle = 0; |
982 | idle = 0; |
846 | nreqs = 0; |
983 | nreqs = 0; |
847 | nready = 0; |
984 | nready = 0; |
848 | npending = 0; |
985 | npending = 0; |
849 | |
986 | |
850 | close (respipe [0]); |
|
|
851 | close (respipe [1]); |
|
|
852 | create_pipe (); |
987 | create_respipe (); |
853 | |
988 | |
854 | atfork_parent (); |
989 | atfork_parent (); |
855 | } |
990 | } |
856 | |
991 | |
857 | #define dREQ(reqtype) \ |
992 | #define dREQ(reqtype) \ |
858 | aio_req req; \ |
993 | bdb_req req; \ |
859 | int req_pri = next_pri; \ |
994 | int req_pri = next_pri; \ |
860 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
995 | next_pri = DEFAULT_PRI + PRI_BIAS; \ |
861 | \ |
996 | \ |
862 | if (SvOK (callback) && !SvROK (callback)) \ |
997 | if (callback && SvOK (callback)) \ |
863 | croak ("callback must be undef or of reference type"); \ |
998 | croak ("callback has illegal type or extra arguments"); \ |
864 | \ |
999 | \ |
865 | Newz (0, req, 1, aio_cb); \ |
1000 | Newz (0, req, 1, bdb_cb); \ |
866 | if (!req) \ |
1001 | if (!req) \ |
867 | croak ("out of memory during aio_req allocation"); \ |
1002 | croak ("out of memory during bdb_req allocation"); \ |
868 | \ |
1003 | \ |
869 | req->callback = newSVsv (callback); \ |
1004 | req->callback = cb ? SvREFCNT_inc (cb) : 0; \ |
870 | req->type = (reqtype); \ |
1005 | req->type = (reqtype); \ |
871 | req->pri = req_pri |
1006 | req->pri = req_pri |
872 | |
1007 | |
873 | #define REQ_SEND \ |
1008 | #define REQ_SEND \ |
874 | req_send (req) |
1009 | req_send (req) |
875 | |
1010 | |
876 | #define SvPTR(var, arg, type, class, nullok) \ |
1011 | #define SvPTR(var, arg, type, class, nullok) \ |
877 | if (!SvOK (arg)) \ |
1012 | if (!SvOK (arg)) \ |
878 | { \ |
1013 | { \ |
879 | if (!nullok) \ |
1014 | if (nullok != 1) \ |
880 | croak (# var " must be a " # class " object, not undef"); \ |
1015 | croak (# var " must be a " # class " object, not undef"); \ |
881 | \ |
1016 | \ |
882 | (var) = 0; \ |
1017 | (var) = 0; \ |
883 | } \ |
1018 | } \ |
884 | else if (sv_derived_from ((arg), # class)) \ |
1019 | else if (sv_derived_from ((arg), # class)) \ |
885 | { \ |
1020 | { \ |
886 | IV tmp = SvIV ((SV*) SvRV (arg)); \ |
1021 | IV tmp = SvIV ((SV*) SvRV (arg)); \ |
887 | (var) = INT2PTR (type, tmp); \ |
1022 | (var) = INT2PTR (type, tmp); \ |
888 | if (!var) \ |
1023 | if (!var && nullok != 2) \ |
889 | croak (# var " is not a valid " # class " object anymore"); \ |
1024 | croak (# var " is not a valid " # class " object anymore"); \ |
890 | } \ |
1025 | } \ |
891 | else \ |
1026 | else \ |
892 | croak (# var " is not of type " # class); \ |
1027 | croak (# var " is not of type " # class); |
893 | \ |
|
|
894 | |
1028 | |
895 | static void |
1029 | static void |
896 | ptr_nuke (SV *sv) |
1030 | ptr_nuke (SV *sv) |
897 | { |
1031 | { |
898 | assert (SvROK (sv)); |
1032 | assert (SvROK (sv)); |
899 | sv_setiv (SvRV (sv), 0); |
1033 | sv_setiv (SvRV (sv), 0); |
900 | } |
1034 | } |
|
|
1035 | |
|
|
1036 | static int |
|
|
1037 | errno_get (pTHX_ SV *sv, MAGIC *mg) |
|
|
1038 | { |
|
|
1039 | if (*mg->mg_ptr == '!') // should always be the case |
|
|
1040 | if (-30999 <= errno && errno <= -30800) |
|
|
1041 | { |
|
|
1042 | sv_setnv (sv, (NV)errno); |
|
|
1043 | sv_setpv (sv, db_strerror (errno)); |
|
|
1044 | SvNOK_on (sv); /* what a wonderful hack! */ |
|
|
1045 | // ^^^ copied from perl sources |
|
|
1046 | return 0; |
|
|
1047 | } |
|
|
1048 | |
|
|
1049 | return PL_vtbl_sv.svt_get (aTHX_ sv, mg); |
|
|
1050 | } |
|
|
1051 | |
|
|
1052 | static MGVTBL vtbl_errno; |
|
|
1053 | |
|
|
1054 | // this wonderful hack :( patches perl's $! variable to support our errno values |
|
|
1055 | static void |
|
|
1056 | patch_errno (void) |
|
|
1057 | { |
|
|
1058 | SV *sv; |
|
|
1059 | MAGIC *mg; |
|
|
1060 | |
|
|
1061 | if (!(sv = get_sv ("!", 1))) |
|
|
1062 | return; |
|
|
1063 | |
|
|
1064 | if (!(mg = mg_find (sv, PERL_MAGIC_sv))) |
|
|
1065 | return; |
|
|
1066 | |
|
|
1067 | if (mg->mg_virtual != &PL_vtbl_sv) |
|
|
1068 | return; |
|
|
1069 | |
|
|
1070 | vtbl_errno = PL_vtbl_sv; |
|
|
1071 | vtbl_errno.svt_get = errno_get; |
|
|
1072 | mg->mg_virtual = &vtbl_errno; |
|
|
1073 | } |
|
|
1074 | |
|
|
1075 | #if __GNUC__ >= 4 |
|
|
1076 | # define noinline __attribute__ ((noinline)) |
|
|
1077 | #else |
|
|
1078 | # define noinline |
|
|
1079 | #endif |
|
|
1080 | |
|
|
1081 | static noinline SV * |
|
|
1082 | pop_callback (I32 *ritems, SV *sv) |
|
|
1083 | { |
|
|
1084 | if (SvROK (sv)) |
|
|
1085 | { |
|
|
1086 | HV *st; |
|
|
1087 | GV *gvp; |
|
|
1088 | CV *cv; |
|
|
1089 | const char *name; |
|
|
1090 | |
|
|
1091 | /* forgive me */ |
|
|
1092 | if (SvTYPE (SvRV (sv)) == SVt_PVMG |
|
|
1093 | && (st = SvSTASH (SvRV (sv))) |
|
|
1094 | && (name = HvNAME_get (st)) |
|
|
1095 | && (name [0] == 'B' && name [1] == 'D' && name [2] == 'B' && name [3] == ':')) |
|
|
1096 | return 0; |
|
|
1097 | |
|
|
1098 | if ((cv = sv_2cv (sv, &st, &gvp, 0))) |
|
|
1099 | { |
|
|
1100 | --*ritems; |
|
|
1101 | return (SV *)cv; |
|
|
1102 | } |
|
|
1103 | } |
|
|
1104 | |
|
|
1105 | return 0; |
|
|
1106 | } |
|
|
1107 | |
|
|
1108 | /* stupid windoes defined CALLBACK as well */ |
|
|
1109 | #undef CALLBACK |
|
|
1110 | #define CALLBACK SV *cb = pop_callback (&items, ST (items - 1)); |
901 | |
1111 | |
902 | MODULE = BDB PACKAGE = BDB |
1112 | MODULE = BDB PACKAGE = BDB |
903 | |
1113 | |
904 | PROTOTYPES: ENABLE |
1114 | PROTOTYPES: ENABLE |
905 | |
1115 | |
… | |
… | |
921 | const_iv (INIT_TXN) |
1131 | const_iv (INIT_TXN) |
922 | const_iv (RECOVER) |
1132 | const_iv (RECOVER) |
923 | const_iv (INIT_TXN) |
1133 | const_iv (INIT_TXN) |
924 | const_iv (RECOVER_FATAL) |
1134 | const_iv (RECOVER_FATAL) |
925 | const_iv (CREATE) |
1135 | const_iv (CREATE) |
|
|
1136 | const_iv (RDONLY) |
926 | const_iv (USE_ENVIRON) |
1137 | const_iv (USE_ENVIRON) |
927 | const_iv (USE_ENVIRON_ROOT) |
1138 | const_iv (USE_ENVIRON_ROOT) |
928 | const_iv (LOCKDOWN) |
1139 | const_iv (LOCKDOWN) |
929 | const_iv (PRIVATE) |
1140 | const_iv (PRIVATE) |
930 | const_iv (REGISTER) |
|
|
931 | const_iv (SYSTEM_MEM) |
1141 | const_iv (SYSTEM_MEM) |
932 | const_iv (AUTO_COMMIT) |
1142 | const_iv (AUTO_COMMIT) |
933 | const_iv (CDB_ALLDB) |
1143 | const_iv (CDB_ALLDB) |
934 | const_iv (DIRECT_DB) |
1144 | const_iv (DIRECT_DB) |
935 | const_iv (DIRECT_LOG) |
|
|
936 | const_iv (DSYNC_DB) |
|
|
937 | const_iv (DSYNC_LOG) |
|
|
938 | const_iv (LOG_AUTOREMOVE) |
|
|
939 | const_iv (LOG_INMEMORY) |
|
|
940 | const_iv (NOLOCKING) |
1145 | const_iv (NOLOCKING) |
941 | const_iv (MULTIVERSION) |
|
|
942 | const_iv (NOMMAP) |
1146 | const_iv (NOMMAP) |
943 | const_iv (NOPANIC) |
1147 | const_iv (NOPANIC) |
944 | const_iv (OVERWRITE) |
1148 | const_iv (OVERWRITE) |
945 | const_iv (PANIC_ENVIRONMENT) |
1149 | const_iv (PANIC_ENVIRONMENT) |
946 | const_iv (REGION_INIT) |
1150 | const_iv (REGION_INIT) |
947 | const_iv (TIME_NOTGRANTED) |
1151 | const_iv (TIME_NOTGRANTED) |
948 | const_iv (TXN_NOSYNC) |
1152 | const_iv (TXN_NOSYNC) |
949 | const_iv (TXN_SNAPSHOT) |
1153 | const_iv (TXN_NOT_DURABLE) |
950 | const_iv (TXN_WRITE_NOSYNC) |
1154 | const_iv (TXN_WRITE_NOSYNC) |
951 | const_iv (WRITECURSOR) |
1155 | const_iv (WRITECURSOR) |
952 | const_iv (YIELDCPU) |
1156 | const_iv (YIELDCPU) |
953 | const_iv (ENCRYPT_AES) |
1157 | const_iv (ENCRYPT_AES) |
954 | const_iv (XA_CREATE) |
1158 | const_iv (XA_CREATE) |
… | |
… | |
956 | const_iv (HASH) |
1160 | const_iv (HASH) |
957 | const_iv (QUEUE) |
1161 | const_iv (QUEUE) |
958 | const_iv (RECNO) |
1162 | const_iv (RECNO) |
959 | const_iv (UNKNOWN) |
1163 | const_iv (UNKNOWN) |
960 | const_iv (EXCL) |
1164 | const_iv (EXCL) |
961 | const_iv (READ_COMMITTED) |
|
|
962 | const_iv (READ_UNCOMMITTED) |
|
|
963 | const_iv (TRUNCATE) |
1165 | const_iv (TRUNCATE) |
964 | const_iv (NOSYNC) |
1166 | const_iv (NOSYNC) |
965 | const_iv (CHKSUM) |
1167 | const_iv (CHKSUM) |
966 | const_iv (ENCRYPT) |
1168 | const_iv (ENCRYPT) |
967 | const_iv (TXN_NOT_DURABLE) |
|
|
968 | const_iv (DUP) |
1169 | const_iv (DUP) |
969 | const_iv (DUPSORT) |
1170 | const_iv (DUPSORT) |
970 | const_iv (RECNUM) |
1171 | const_iv (RECNUM) |
971 | const_iv (RENUMBER) |
1172 | const_iv (RENUMBER) |
972 | const_iv (REVSPLITOFF) |
1173 | const_iv (REVSPLITOFF) |
973 | const_iv (INORDER) |
|
|
974 | const_iv (CONSUME) |
1174 | const_iv (CONSUME) |
975 | const_iv (CONSUME_WAIT) |
1175 | const_iv (CONSUME_WAIT) |
976 | const_iv (GET_BOTH) |
1176 | const_iv (GET_BOTH) |
977 | const_iv (GET_BOTH_RANGE) |
1177 | const_iv (GET_BOTH_RANGE) |
978 | //const_iv (SET_RECNO) |
1178 | //const_iv (SET_RECNO) |
979 | //const_iv (MULTIPLE) |
1179 | //const_iv (MULTIPLE) |
980 | const_iv (SNAPSHOT) |
1180 | const_iv (SNAPSHOT) |
981 | const_iv (JOIN_ITEM) |
1181 | const_iv (JOIN_ITEM) |
|
|
1182 | const_iv (JOIN_NOSORT) |
982 | const_iv (RMW) |
1183 | const_iv (RMW) |
983 | |
1184 | |
984 | const_iv (NOTFOUND) |
1185 | const_iv (NOTFOUND) |
985 | const_iv (KEYEMPTY) |
1186 | const_iv (KEYEMPTY) |
986 | const_iv (LOCK_DEADLOCK) |
1187 | const_iv (LOCK_DEADLOCK) |
987 | const_iv (LOCK_NOTGRANTED) |
1188 | const_iv (LOCK_NOTGRANTED) |
988 | const_iv (RUNRECOVERY) |
1189 | const_iv (RUNRECOVERY) |
989 | const_iv (OLD_VERSION) |
1190 | const_iv (OLD_VERSION) |
990 | const_iv (REP_HANDLE_DEAD) |
1191 | const_iv (REP_HANDLE_DEAD) |
991 | const_iv (REP_LOCKOUT) |
|
|
992 | const_iv (SECONDARY_BAD) |
1192 | const_iv (SECONDARY_BAD) |
993 | |
|
|
994 | const_iv (FREE_SPACE) |
|
|
995 | const_iv (FREELIST_ONLY) |
|
|
996 | |
1193 | |
997 | const_iv (APPEND) |
1194 | const_iv (APPEND) |
998 | const_iv (NODUPDATA) |
1195 | const_iv (NODUPDATA) |
999 | const_iv (NOOVERWRITE) |
1196 | const_iv (NOOVERWRITE) |
1000 | |
1197 | |
1001 | const_iv (TXN_NOWAIT) |
1198 | const_iv (TXN_NOWAIT) |
1002 | const_iv (TXN_SNAPSHOT) |
|
|
1003 | const_iv (TXN_SYNC) |
1199 | const_iv (TXN_SYNC) |
1004 | |
1200 | |
1005 | const_iv (SET_LOCK_TIMEOUT) |
1201 | const_iv (SET_LOCK_TIMEOUT) |
1006 | const_iv (SET_TXN_TIMEOUT) |
1202 | const_iv (SET_TXN_TIMEOUT) |
1007 | |
1203 | |
1008 | const_iv (JOIN_ITEM) |
|
|
1009 | const_iv (FIRST) |
1204 | const_iv (FIRST) |
1010 | const_iv (NEXT) |
1205 | const_iv (NEXT) |
1011 | const_iv (NEXT_DUP) |
1206 | const_iv (NEXT_DUP) |
1012 | const_iv (NEXT_NODUP) |
1207 | const_iv (NEXT_NODUP) |
1013 | const_iv (PREV) |
1208 | const_iv (PREV) |
… | |
… | |
1025 | const_iv (FORCE) |
1220 | const_iv (FORCE) |
1026 | |
1221 | |
1027 | const_iv (LOCK_DEFAULT) |
1222 | const_iv (LOCK_DEFAULT) |
1028 | const_iv (LOCK_EXPIRE) |
1223 | const_iv (LOCK_EXPIRE) |
1029 | const_iv (LOCK_MAXLOCKS) |
1224 | const_iv (LOCK_MAXLOCKS) |
1030 | const_iv (LOCK_MAXWRITE) |
|
|
1031 | const_iv (LOCK_MINLOCKS) |
1225 | const_iv (LOCK_MINLOCKS) |
1032 | const_iv (LOCK_MINWRITE) |
1226 | const_iv (LOCK_MINWRITE) |
1033 | const_iv (LOCK_OLDEST) |
1227 | const_iv (LOCK_OLDEST) |
1034 | const_iv (LOCK_RANDOM) |
1228 | const_iv (LOCK_RANDOM) |
1035 | const_iv (LOCK_YOUNGEST) |
1229 | const_iv (LOCK_YOUNGEST) |
1036 | |
1230 | |
|
|
1231 | const_iv (DONOTINDEX) |
|
|
1232 | const_iv (KEYEMPTY ) |
|
|
1233 | const_iv (KEYEXIST ) |
|
|
1234 | const_iv (LOCK_DEADLOCK) |
|
|
1235 | const_iv (LOCK_NOTGRANTED) |
|
|
1236 | const_iv (NOSERVER) |
|
|
1237 | const_iv (NOSERVER_HOME) |
|
|
1238 | const_iv (NOSERVER_ID) |
|
|
1239 | const_iv (NOTFOUND) |
|
|
1240 | const_iv (PAGE_NOTFOUND) |
|
|
1241 | const_iv (REP_DUPMASTER) |
|
|
1242 | const_iv (REP_HANDLE_DEAD) |
|
|
1243 | const_iv (REP_HOLDELECTION) |
|
|
1244 | const_iv (REP_ISPERM) |
|
|
1245 | const_iv (REP_NEWMASTER) |
|
|
1246 | const_iv (REP_NEWSITE) |
|
|
1247 | const_iv (REP_NOTPERM) |
|
|
1248 | const_iv (REP_UNAVAIL) |
|
|
1249 | const_iv (RUNRECOVERY) |
|
|
1250 | const_iv (SECONDARY_BAD) |
|
|
1251 | const_iv (VERIFY_BAD) |
|
|
1252 | |
|
|
1253 | const_iv (VERB_DEADLOCK) |
|
|
1254 | const_iv (VERB_RECOVERY) |
|
|
1255 | const_iv (VERB_REPLICATION) |
|
|
1256 | const_iv (VERB_WAITSFOR) |
|
|
1257 | |
|
|
1258 | const_iv (VERSION_MAJOR) |
|
|
1259 | const_iv (VERSION_MINOR) |
|
|
1260 | const_iv (VERSION_PATCH) |
|
|
1261 | #if DB_VERSION_MINOR >= 3 |
|
|
1262 | const_iv (INORDER) |
|
|
1263 | const_iv (LOCK_MAXWRITE) |
1037 | const_iv (SEQ_DEC) |
1264 | const_iv (SEQ_DEC) |
1038 | const_iv (SEQ_INC) |
1265 | const_iv (SEQ_INC) |
1039 | const_iv (SEQ_WRAP) |
1266 | const_iv (SEQ_WRAP) |
|
|
1267 | const_iv (BUFFER_SMALL) |
|
|
1268 | const_iv (LOG_BUFFER_FULL) |
|
|
1269 | const_iv (VERSION_MISMATCH) |
|
|
1270 | #endif |
|
|
1271 | #if DB_VERSION_MINOR >= 4 |
|
|
1272 | const_iv (REGISTER) |
|
|
1273 | const_iv (DSYNC_DB) |
|
|
1274 | const_iv (READ_COMMITTED) |
|
|
1275 | const_iv (READ_UNCOMMITTED) |
|
|
1276 | const_iv (REP_IGNORE) |
|
|
1277 | const_iv (REP_LOCKOUT) |
|
|
1278 | const_iv (REP_JOIN_FAILURE) |
|
|
1279 | const_iv (FREE_SPACE) |
|
|
1280 | const_iv (FREELIST_ONLY) |
|
|
1281 | const_iv (VERB_REGISTER) |
|
|
1282 | #endif |
|
|
1283 | #if DB_VERSION_MINOR >= 5 |
|
|
1284 | const_iv (MULTIVERSION) |
|
|
1285 | const_iv (TXN_SNAPSHOT) |
|
|
1286 | #endif |
|
|
1287 | #if DB_VERSION_MINOR >= 6 |
|
|
1288 | const_iv (PREV_DUP) |
|
|
1289 | const_iv (PRIORITY_UNCHANGED) |
|
|
1290 | const_iv (PRIORITY_VERY_LOW) |
|
|
1291 | const_iv (PRIORITY_LOW) |
|
|
1292 | const_iv (PRIORITY_DEFAULT) |
|
|
1293 | const_iv (PRIORITY_HIGH) |
|
|
1294 | const_iv (PRIORITY_VERY_HIGH) |
|
|
1295 | #endif |
|
|
1296 | #if DB_VERSION_MINOR >= 7 |
|
|
1297 | const_iv (LOG_DIRECT) |
|
|
1298 | const_iv (LOG_DSYNC) |
|
|
1299 | const_iv (LOG_AUTO_REMOVE) |
|
|
1300 | const_iv (LOG_IN_MEMORY) |
|
|
1301 | const_iv (LOG_ZERO) |
|
|
1302 | #else |
|
|
1303 | const_iv (DIRECT_LOG) |
|
|
1304 | const_iv (LOG_AUTOREMOVE) |
|
|
1305 | # if DB_VERSION_MINOR >= 3 |
|
|
1306 | const_iv (DSYNC_LOG) |
|
|
1307 | const_iv (LOG_INMEMORY) |
|
|
1308 | # endif |
|
|
1309 | #endif |
1040 | }; |
1310 | }; |
1041 | |
1311 | |
1042 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1312 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
1043 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1313 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
1044 | |
1314 | |
1045 | create_pipe (); |
1315 | { |
|
|
1316 | /* we currently only allow version, minor-version and patchlevel to go up to 255 */ |
|
|
1317 | char vstring[3] = { DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH }; |
|
|
1318 | |
|
|
1319 | newCONSTSUB (stash, "VERSION_v", newSVpvn (vstring, 3)); |
|
|
1320 | } |
|
|
1321 | |
|
|
1322 | newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
|
|
1323 | |
|
|
1324 | create_respipe (); |
|
|
1325 | |
1046 | pthread_atfork (atfork_prepare, atfork_parent, atfork_child); |
1326 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
|
|
1327 | patch_errno (); |
1047 | } |
1328 | } |
1048 | |
1329 | |
1049 | void |
1330 | void |
1050 | max_poll_reqs (int nreqs) |
1331 | max_poll_reqs (int nreqs) |
1051 | PROTOTYPE: $ |
1332 | PROTOTYPE: $ |
… | |
… | |
1170 | |
1451 | |
1171 | int |
1452 | int |
1172 | nthreads () |
1453 | nthreads () |
1173 | PROTOTYPE: |
1454 | PROTOTYPE: |
1174 | CODE: |
1455 | CODE: |
1175 | if (WORDACCESS_UNSAFE) LOCK (wrklock); |
1456 | if (WORDACCESS_UNSAFE) X_LOCK (wrklock); |
1176 | RETVAL = started; |
1457 | RETVAL = started; |
1177 | if (WORDACCESS_UNSAFE) UNLOCK (wrklock); |
1458 | if (WORDACCESS_UNSAFE) X_UNLOCK (wrklock); |
1178 | OUTPUT: |
1459 | OUTPUT: |
1179 | RETVAL |
1460 | RETVAL |
1180 | |
1461 | |
1181 | void |
1462 | void |
1182 | set_sync_prepare (SV *cb) |
1463 | set_sync_prepare (SV *cb) |
1183 | PROTOTYPE: & |
1464 | PROTOTYPE: & |
1184 | CODE: |
1465 | CODE: |
1185 | SvREFCNT_dec (prepare_cb); |
1466 | SvREFCNT_dec (prepare_cb); |
1186 | prepare_cb = newSVsv (cb); |
1467 | prepare_cb = newSVsv (cb); |
1187 | |
1468 | |
|
|
1469 | char * |
|
|
1470 | strerror (int errorno = errno) |
|
|
1471 | PROTOTYPE: ;$ |
|
|
1472 | CODE: |
|
|
1473 | RETVAL = db_strerror (errorno); |
|
|
1474 | OUTPUT: |
|
|
1475 | RETVAL |
|
|
1476 | |
|
|
1477 | void _on_next_submit (SV *cb) |
|
|
1478 | CODE: |
|
|
1479 | SvREFCNT_dec (on_next_submit); |
|
|
1480 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1188 | |
1481 | |
1189 | DB_ENV * |
1482 | DB_ENV * |
1190 | db_env_create (U32 env_flags = 0) |
1483 | db_env_create (U32 env_flags = 0) |
1191 | CODE: |
1484 | CODE: |
1192 | { |
1485 | { |
1193 | errno = db_env_create (&RETVAL, env_flags); |
1486 | errno = db_env_create (&RETVAL, env_flags); |
1194 | if (errno) |
1487 | if (errno) |
1195 | croak ("db_env_create: %s", db_strerror (errno)); |
1488 | croak ("db_env_create: %s", db_strerror (errno)); |
|
|
1489 | |
|
|
1490 | if (0) |
|
|
1491 | { |
|
|
1492 | RETVAL->set_errcall (RETVAL, debug_errcall); |
|
|
1493 | RETVAL->set_msgcall (RETVAL, debug_msgcall); |
|
|
1494 | } |
1196 | } |
1495 | } |
1197 | OUTPUT: |
1496 | OUTPUT: |
1198 | RETVAL |
1497 | RETVAL |
1199 | |
1498 | |
1200 | void |
1499 | void |
1201 | db_env_open (DB_ENV *env, octetstring db_home, U32 open_flags, int mode, SV *callback = &PL_sv_undef) |
1500 | db_env_open (DB_ENV *env, bdb_filename db_home, U32 open_flags, int mode, SV *callback = 0) |
|
|
1501 | PREINIT: |
|
|
1502 | CALLBACK |
1202 | CODE: |
1503 | CODE: |
1203 | { |
1504 | { |
1204 | env->set_thread_count (env, get_nthreads ()); |
|
|
1205 | |
|
|
1206 | dREQ (REQ_ENV_OPEN); |
1505 | dREQ (REQ_ENV_OPEN); |
1207 | req->env = env; |
1506 | req->env = env; |
1208 | req->uint1 = open_flags | DB_THREAD; |
1507 | req->uint1 = open_flags | DB_THREAD; |
1209 | req->int1 = mode; |
1508 | req->int1 = mode; |
1210 | req->buf1 = strdup_ornull (db_home); |
1509 | req->buf1 = strdup_ornull (db_home); |
1211 | REQ_SEND; |
1510 | REQ_SEND; |
1212 | } |
1511 | } |
1213 | |
1512 | |
1214 | void |
1513 | void |
1215 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = &PL_sv_undef) |
1514 | db_env_close (DB_ENV *env, U32 flags = 0, SV *callback = 0) |
|
|
1515 | PREINIT: |
|
|
1516 | CALLBACK |
1216 | CODE: |
1517 | CODE: |
1217 | { |
1518 | { |
1218 | dREQ (REQ_ENV_CLOSE); |
1519 | dREQ (REQ_ENV_CLOSE); |
1219 | req->env = env; |
1520 | req->env = env; |
1220 | req->uint1 = flags; |
1521 | req->uint1 = flags; |
1221 | REQ_SEND; |
1522 | REQ_SEND; |
1222 | ptr_nuke (ST (0)); |
1523 | ptr_nuke (ST (0)); |
1223 | } |
1524 | } |
1224 | |
1525 | |
1225 | void |
1526 | void |
1226 | db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = &PL_sv_undef) |
1527 | db_env_txn_checkpoint (DB_ENV *env, U32 kbyte = 0, U32 min = 0, U32 flags = 0, SV *callback = 0) |
|
|
1528 | PREINIT: |
|
|
1529 | CALLBACK |
1227 | CODE: |
1530 | CODE: |
1228 | { |
1531 | { |
1229 | dREQ (REQ_ENV_TXN_CHECKPOINT); |
1532 | dREQ (REQ_ENV_TXN_CHECKPOINT); |
1230 | req->env = env; |
1533 | req->env = env; |
1231 | req->uint1 = kbyte; |
1534 | req->uint1 = kbyte; |
… | |
… | |
1233 | req->uint2 = flags; |
1536 | req->uint2 = flags; |
1234 | REQ_SEND; |
1537 | REQ_SEND; |
1235 | } |
1538 | } |
1236 | |
1539 | |
1237 | void |
1540 | void |
1238 | db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1541 | db_env_lock_detect (DB_ENV *env, U32 flags = 0, U32 atype = DB_LOCK_DEFAULT, SV *dummy = 0, SV *callback = 0) |
|
|
1542 | PREINIT: |
|
|
1543 | CALLBACK |
1239 | CODE: |
1544 | CODE: |
1240 | { |
1545 | { |
1241 | dREQ (REQ_ENV_LOCK_DETECT); |
1546 | dREQ (REQ_ENV_LOCK_DETECT); |
1242 | req->env = env; |
1547 | req->env = env; |
1243 | req->uint1 = flags; |
1548 | req->uint1 = flags; |
1244 | req->uint2 = atype; |
1549 | req->uint2 = atype; |
|
|
1550 | /* req->int2 = 0; dummy */ |
1245 | REQ_SEND; |
1551 | REQ_SEND; |
1246 | } |
1552 | } |
1247 | |
1553 | |
1248 | void |
1554 | void |
1249 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1555 | db_env_memp_sync (DB_ENV *env, SV *dummy = 0, SV *callback = 0) |
|
|
1556 | PREINIT: |
|
|
1557 | CALLBACK |
1250 | CODE: |
1558 | CODE: |
1251 | { |
1559 | { |
1252 | dREQ (REQ_ENV_MEMP_SYNC); |
1560 | dREQ (REQ_ENV_MEMP_SYNC); |
1253 | req->env = env; |
1561 | req->env = env; |
1254 | REQ_SEND; |
1562 | REQ_SEND; |
1255 | } |
1563 | } |
1256 | |
1564 | |
1257 | void |
1565 | void |
1258 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = &PL_sv_undef) |
1566 | db_env_memp_trickle (DB_ENV *env, int percent, SV *dummy = 0, SV *callback = 0) |
|
|
1567 | PREINIT: |
|
|
1568 | CALLBACK |
1259 | CODE: |
1569 | CODE: |
1260 | { |
1570 | { |
1261 | dREQ (REQ_ENV_MEMP_TRICKLE); |
1571 | dREQ (REQ_ENV_MEMP_TRICKLE); |
1262 | req->env = env; |
1572 | req->env = env; |
1263 | req->int1 = percent; |
1573 | req->int1 = percent; |
1264 | REQ_SEND; |
1574 | REQ_SEND; |
1265 | } |
1575 | } |
1266 | |
1576 | |
|
|
1577 | void |
|
|
1578 | db_env_dbremove (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, U32 flags = 0, SV *callback = 0) |
|
|
1579 | PREINIT: |
|
|
1580 | CALLBACK |
|
|
1581 | CODE: |
|
|
1582 | { |
|
|
1583 | dREQ (REQ_ENV_DBREMOVE); |
|
|
1584 | req->env = env; |
|
|
1585 | req->buf1 = strdup_ornull (file); |
|
|
1586 | req->buf2 = strdup_ornull (database); |
|
|
1587 | req->uint1 = flags; |
|
|
1588 | REQ_SEND; |
|
|
1589 | } |
|
|
1590 | |
|
|
1591 | void |
|
|
1592 | db_env_dbrename (DB_ENV *env, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, bdb_filename newname, U32 flags = 0, SV *callback = 0) |
|
|
1593 | PREINIT: |
|
|
1594 | CALLBACK |
|
|
1595 | CODE: |
|
|
1596 | { |
|
|
1597 | dREQ (REQ_ENV_DBRENAME); |
|
|
1598 | req->env = env; |
|
|
1599 | req->buf1 = strdup_ornull (file); |
|
|
1600 | req->buf2 = strdup_ornull (database); |
|
|
1601 | req->buf3 = strdup_ornull (newname); |
|
|
1602 | req->uint1 = flags; |
|
|
1603 | REQ_SEND; |
|
|
1604 | } |
1267 | |
1605 | |
1268 | DB * |
1606 | DB * |
1269 | db_create (DB_ENV *env = 0, U32 flags = 0) |
1607 | db_create (DB_ENV *env = 0, U32 flags = 0) |
1270 | CODE: |
1608 | CODE: |
1271 | { |
1609 | { |
… | |
… | |
1278 | } |
1616 | } |
1279 | OUTPUT: |
1617 | OUTPUT: |
1280 | RETVAL |
1618 | RETVAL |
1281 | |
1619 | |
1282 | void |
1620 | void |
1283 | db_open (DB *db, DB_TXN_ornull *txnid, octetstring file, octetstring database, int type, U32 flags, int mode, SV *callback = &PL_sv_undef) |
1621 | db_open (DB *db, DB_TXN_ornull *txnid, bdb_filename file, bdb_filename database, int type, U32 flags, int mode, SV *callback = 0) |
|
|
1622 | PREINIT: |
|
|
1623 | CALLBACK |
1284 | CODE: |
1624 | CODE: |
1285 | { |
1625 | { |
1286 | dREQ (REQ_DB_OPEN); |
1626 | dREQ (REQ_DB_OPEN); |
1287 | req->db = db; |
1627 | req->db = db; |
1288 | req->txn = txnid; |
1628 | req->txn = txnid; |
… | |
… | |
1293 | req->int2 = mode; |
1633 | req->int2 = mode; |
1294 | REQ_SEND; |
1634 | REQ_SEND; |
1295 | } |
1635 | } |
1296 | |
1636 | |
1297 | void |
1637 | void |
1298 | db_close (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
1638 | db_close (DB *db, U32 flags = 0, SV *callback = 0) |
|
|
1639 | PREINIT: |
|
|
1640 | CALLBACK |
1299 | CODE: |
1641 | CODE: |
1300 | { |
1642 | { |
1301 | dREQ (REQ_DB_CLOSE); |
1643 | dREQ (REQ_DB_CLOSE); |
1302 | req->db = db; |
1644 | req->db = db; |
1303 | req->uint1 = flags; |
1645 | req->uint1 = flags; |
1304 | req->sv1 = (SV *)db->app_private; |
1646 | req->sv1 = (SV *)db->app_private; |
1305 | REQ_SEND; |
1647 | REQ_SEND; |
1306 | ptr_nuke (ST (0)); |
1648 | ptr_nuke (ST (0)); |
1307 | } |
1649 | } |
1308 | |
1650 | |
|
|
1651 | #if DB_VERSION_MINOR >= 4 |
|
|
1652 | |
1309 | void |
1653 | void |
1310 | db_compact (DB *db, DB_TXN_ornull *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = &PL_sv_undef) |
1654 | db_compact (DB *db, DB_TXN_ornull *txn = 0, SV *start = 0, SV *stop = 0, SV *unused1 = 0, U32 flags = DB_FREE_SPACE, SV *unused2 = 0, SV *callback = 0) |
|
|
1655 | PREINIT: |
|
|
1656 | CALLBACK |
1311 | CODE: |
1657 | CODE: |
1312 | { |
1658 | { |
1313 | dREQ (REQ_DB_COMPACT); |
1659 | dREQ (REQ_DB_COMPACT); |
1314 | req->db = db; |
1660 | req->db = db; |
1315 | req->txn = txn; |
1661 | req->txn = txn; |
… | |
… | |
1317 | sv_to_dbt (&req->dbt2, stop); |
1663 | sv_to_dbt (&req->dbt2, stop); |
1318 | req->uint1 = flags; |
1664 | req->uint1 = flags; |
1319 | REQ_SEND; |
1665 | REQ_SEND; |
1320 | } |
1666 | } |
1321 | |
1667 | |
|
|
1668 | #endif |
|
|
1669 | |
1322 | void |
1670 | void |
1323 | db_sync (DB *db, U32 flags = 0, SV *callback = &PL_sv_undef) |
1671 | db_sync (DB *db, U32 flags = 0, SV *callback = 0) |
|
|
1672 | PREINIT: |
|
|
1673 | CALLBACK |
1324 | CODE: |
1674 | CODE: |
1325 | { |
1675 | { |
1326 | dREQ (REQ_DB_SYNC); |
1676 | dREQ (REQ_DB_SYNC); |
1327 | req->db = db; |
1677 | req->db = db; |
1328 | req->uint1 = flags; |
1678 | req->uint1 = flags; |
1329 | REQ_SEND; |
1679 | REQ_SEND; |
1330 | } |
1680 | } |
1331 | |
1681 | |
1332 | void |
1682 | void |
|
|
1683 | db_upgrade (DB *db, bdb_filename file, U32 flags = 0, SV *callback = 0) |
|
|
1684 | PREINIT: |
|
|
1685 | CALLBACK |
|
|
1686 | CODE: |
|
|
1687 | { |
|
|
1688 | dREQ (REQ_DB_SYNC); |
|
|
1689 | req->db = db; |
|
|
1690 | req->buf1 = strdup (file); |
|
|
1691 | req->uint1 = flags; |
|
|
1692 | REQ_SEND; |
|
|
1693 | } |
|
|
1694 | |
|
|
1695 | void |
1333 | db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = &PL_sv_undef) |
1696 | db_key_range (DB *db, DB_TXN_ornull *txn, SV *key, SV *key_range, U32 flags = 0, SV *callback = 0) |
|
|
1697 | PREINIT: |
|
|
1698 | CALLBACK |
1334 | CODE: |
1699 | CODE: |
1335 | { |
1700 | { |
1336 | dREQ (REQ_DB_KEY_RANGE); |
1701 | dREQ (REQ_DB_KEY_RANGE); |
1337 | req->db = db; |
1702 | req->db = db; |
1338 | req->txn = txn; |
1703 | req->txn = txn; |
… | |
… | |
1341 | req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1706 | req->sv1 = SvREFCNT_inc (key_range); SvREADONLY_on (key_range); |
1342 | REQ_SEND; |
1707 | REQ_SEND; |
1343 | } |
1708 | } |
1344 | |
1709 | |
1345 | void |
1710 | void |
1346 | db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1711 | db_put (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1712 | PREINIT: |
|
|
1713 | CALLBACK |
1347 | CODE: |
1714 | CODE: |
1348 | { |
1715 | { |
1349 | dREQ (REQ_DB_PUT); |
1716 | dREQ (REQ_DB_PUT); |
1350 | req->db = db; |
1717 | req->db = db; |
1351 | req->txn = txn; |
1718 | req->txn = txn; |
… | |
… | |
1353 | sv_to_dbt (&req->dbt2, data); |
1720 | sv_to_dbt (&req->dbt2, data); |
1354 | req->uint1 = flags; |
1721 | req->uint1 = flags; |
1355 | REQ_SEND; |
1722 | REQ_SEND; |
1356 | } |
1723 | } |
1357 | |
1724 | |
|
|
1725 | #if DB_VERSION_MINOR >= 6 |
|
|
1726 | |
1358 | void |
1727 | void |
|
|
1728 | db_exists (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1729 | PREINIT: |
|
|
1730 | CALLBACK |
|
|
1731 | CODE: |
|
|
1732 | { |
|
|
1733 | dREQ (REQ_DB_EXISTS); |
|
|
1734 | req->db = db; |
|
|
1735 | req->txn = txn; |
|
|
1736 | req->uint1 = flags; |
|
|
1737 | sv_to_dbt (&req->dbt1, key); |
|
|
1738 | REQ_SEND; |
|
|
1739 | } |
|
|
1740 | |
|
|
1741 | #endif |
|
|
1742 | |
|
|
1743 | void |
1359 | db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1744 | db_get (DB *db, DB_TXN_ornull *txn, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1745 | PREINIT: |
|
|
1746 | CALLBACK |
1360 | CODE: |
1747 | CODE: |
|
|
1748 | if (SvREADONLY (data)) |
|
|
1749 | croak ("can't modify read-only data scalar in db_get"); |
1361 | { |
1750 | { |
1362 | dREQ (REQ_DB_GET); |
1751 | dREQ (REQ_DB_GET); |
1363 | req->db = db; |
1752 | req->db = db; |
1364 | req->txn = txn; |
1753 | req->txn = txn; |
1365 | req->uint1 = flags; |
1754 | req->uint1 = flags; |
… | |
… | |
1368 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1757 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1369 | REQ_SEND; |
1758 | REQ_SEND; |
1370 | } |
1759 | } |
1371 | |
1760 | |
1372 | void |
1761 | void |
1373 | db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1762 | db_pget (DB *db, DB_TXN_ornull *txn, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1763 | PREINIT: |
|
|
1764 | CALLBACK |
1374 | CODE: |
1765 | CODE: |
|
|
1766 | if (SvREADONLY (data)) |
|
|
1767 | croak ("can't modify read-only data scalar in db_pget"); |
1375 | { |
1768 | { |
1376 | dREQ (REQ_DB_PGET); |
1769 | dREQ (REQ_DB_PGET); |
1377 | req->db = db; |
1770 | req->db = db; |
1378 | req->txn = txn; |
1771 | req->txn = txn; |
1379 | req->uint1 = flags; |
1772 | req->uint1 = flags; |
… | |
… | |
1383 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1776 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1384 | REQ_SEND; |
1777 | REQ_SEND; |
1385 | } |
1778 | } |
1386 | |
1779 | |
1387 | void |
1780 | void |
1388 | db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = &PL_sv_undef) |
1781 | db_del (DB *db, DB_TXN_ornull *txn, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1782 | PREINIT: |
|
|
1783 | CALLBACK |
1389 | CODE: |
1784 | CODE: |
1390 | { |
1785 | { |
1391 | dREQ (REQ_DB_DEL); |
1786 | dREQ (REQ_DB_DEL); |
1392 | req->db = db; |
1787 | req->db = db; |
1393 | req->txn = txn; |
1788 | req->txn = txn; |
… | |
… | |
1395 | sv_to_dbt (&req->dbt1, key); |
1790 | sv_to_dbt (&req->dbt1, key); |
1396 | REQ_SEND; |
1791 | REQ_SEND; |
1397 | } |
1792 | } |
1398 | |
1793 | |
1399 | void |
1794 | void |
1400 | db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = &PL_sv_undef) |
1795 | db_txn_commit (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
|
|
1796 | PREINIT: |
|
|
1797 | CALLBACK |
1401 | CODE: |
1798 | CODE: |
1402 | { |
1799 | { |
1403 | dREQ (REQ_TXN_COMMIT); |
1800 | dREQ (REQ_TXN_COMMIT); |
1404 | req->txn = txn; |
1801 | req->txn = txn; |
1405 | req->uint1 = flags; |
1802 | req->uint1 = flags; |
1406 | REQ_SEND; |
1803 | REQ_SEND; |
1407 | ptr_nuke (ST (0)); |
1804 | ptr_nuke (ST (0)); |
1408 | } |
1805 | } |
1409 | |
1806 | |
1410 | void |
1807 | void |
1411 | db_txn_abort (DB_TXN *txn, SV *callback = &PL_sv_undef) |
1808 | db_txn_abort (DB_TXN *txn, SV *callback = 0) |
|
|
1809 | PREINIT: |
|
|
1810 | CALLBACK |
1412 | CODE: |
1811 | CODE: |
1413 | { |
1812 | { |
1414 | dREQ (REQ_TXN_ABORT); |
1813 | dREQ (REQ_TXN_ABORT); |
1415 | req->txn = txn; |
1814 | req->txn = txn; |
1416 | REQ_SEND; |
1815 | REQ_SEND; |
1417 | ptr_nuke (ST (0)); |
1816 | ptr_nuke (ST (0)); |
1418 | } |
1817 | } |
1419 | |
1818 | |
1420 | void |
1819 | void |
|
|
1820 | db_txn_finish (DB_TXN *txn, U32 flags = 0, SV *callback = 0) |
|
|
1821 | PREINIT: |
|
|
1822 | CALLBACK |
|
|
1823 | CODE: |
|
|
1824 | { |
|
|
1825 | dREQ (REQ_TXN_FINISH); |
|
|
1826 | req->txn = txn; |
|
|
1827 | req->uint1 = flags; |
|
|
1828 | REQ_SEND; |
|
|
1829 | ptr_nuke (ST (0)); |
|
|
1830 | } |
|
|
1831 | |
|
|
1832 | void |
1421 | db_c_close (DBC *dbc, SV *callback = &PL_sv_undef) |
1833 | db_c_close (DBC *dbc, SV *callback = 0) |
|
|
1834 | PREINIT: |
|
|
1835 | CALLBACK |
1422 | CODE: |
1836 | CODE: |
1423 | { |
1837 | { |
1424 | dREQ (REQ_C_CLOSE); |
1838 | dREQ (REQ_C_CLOSE); |
1425 | req->dbc = dbc; |
1839 | req->dbc = dbc; |
1426 | REQ_SEND; |
1840 | REQ_SEND; |
1427 | ptr_nuke (ST (0)); |
1841 | ptr_nuke (ST (0)); |
1428 | } |
1842 | } |
1429 | |
1843 | |
1430 | void |
1844 | void |
1431 | db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = &PL_sv_undef) |
1845 | db_c_count (DBC *dbc, SV *count, U32 flags = 0, SV *callback = 0) |
|
|
1846 | PREINIT: |
|
|
1847 | CALLBACK |
1432 | CODE: |
1848 | CODE: |
1433 | { |
1849 | { |
1434 | dREQ (REQ_C_COUNT); |
1850 | dREQ (REQ_C_COUNT); |
1435 | req->dbc = dbc; |
1851 | req->dbc = dbc; |
1436 | req->sv1 = SvREFCNT_inc (count); |
1852 | req->sv1 = SvREFCNT_inc (count); |
1437 | REQ_SEND; |
1853 | REQ_SEND; |
1438 | } |
1854 | } |
1439 | |
1855 | |
1440 | void |
1856 | void |
1441 | db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1857 | db_c_put (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1858 | PREINIT: |
|
|
1859 | CALLBACK |
1442 | CODE: |
1860 | CODE: |
1443 | { |
1861 | { |
1444 | dREQ (REQ_C_PUT); |
1862 | dREQ (REQ_C_PUT); |
1445 | req->dbc = dbc; |
1863 | req->dbc = dbc; |
1446 | sv_to_dbt (&req->dbt1, key); |
1864 | sv_to_dbt (&req->dbt1, key); |
… | |
… | |
1448 | req->uint1 = flags; |
1866 | req->uint1 = flags; |
1449 | REQ_SEND; |
1867 | REQ_SEND; |
1450 | } |
1868 | } |
1451 | |
1869 | |
1452 | void |
1870 | void |
1453 | db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1871 | db_c_get (DBC *dbc, SV *key, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1872 | PREINIT: |
|
|
1873 | CALLBACK |
1454 | CODE: |
1874 | CODE: |
1455 | { |
1875 | { |
1456 | dREQ (REQ_C_GET); |
1876 | dREQ (REQ_C_GET); |
1457 | req->dbc = dbc; |
1877 | req->dbc = dbc; |
1458 | req->uint1 = flags; |
1878 | req->uint1 = flags; |
… | |
… | |
1473 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1893 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1474 | REQ_SEND; |
1894 | REQ_SEND; |
1475 | } |
1895 | } |
1476 | |
1896 | |
1477 | void |
1897 | void |
1478 | db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = &PL_sv_undef) |
1898 | db_c_pget (DBC *dbc, SV *key, SV *pkey, SV *data, U32 flags = 0, SV *callback = 0) |
|
|
1899 | PREINIT: |
|
|
1900 | CALLBACK |
1479 | CODE: |
1901 | CODE: |
1480 | { |
1902 | { |
1481 | dREQ (REQ_C_PGET); |
1903 | dREQ (REQ_C_PGET); |
1482 | req->dbc = dbc; |
1904 | req->dbc = dbc; |
1483 | req->uint1 = flags; |
1905 | req->uint1 = flags; |
… | |
… | |
1501 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1923 | req->sv3 = SvREFCNT_inc (data); SvREADONLY_on (data); |
1502 | REQ_SEND; |
1924 | REQ_SEND; |
1503 | } |
1925 | } |
1504 | |
1926 | |
1505 | void |
1927 | void |
1506 | db_c_del (DBC *dbc, U32 flags = 0, SV *callback = &PL_sv_undef) |
1928 | db_c_del (DBC *dbc, U32 flags = 0, SV *callback = 0) |
|
|
1929 | PREINIT: |
|
|
1930 | CALLBACK |
1507 | CODE: |
1931 | CODE: |
1508 | { |
1932 | { |
1509 | dREQ (REQ_C_DEL); |
1933 | dREQ (REQ_C_DEL); |
1510 | req->dbc = dbc; |
1934 | req->dbc = dbc; |
1511 | req->uint1 = flags; |
1935 | req->uint1 = flags; |
1512 | REQ_SEND; |
1936 | REQ_SEND; |
1513 | } |
1937 | } |
1514 | |
1938 | |
1515 | |
1939 | |
|
|
1940 | #if DB_VERSION_MINOR >= 3 |
|
|
1941 | |
1516 | void |
1942 | void |
1517 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = &PL_sv_undef) |
1943 | db_sequence_open (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, SV *key, U32 flags = 0, SV *callback = 0) |
|
|
1944 | PREINIT: |
|
|
1945 | CALLBACK |
1518 | CODE: |
1946 | CODE: |
1519 | { |
1947 | { |
1520 | dREQ (REQ_SEQ_OPEN); |
1948 | dREQ (REQ_SEQ_OPEN); |
1521 | req->seq = seq; |
1949 | req->seq = seq; |
1522 | req->txn = txnid; |
1950 | req->txn = txnid; |
… | |
… | |
1524 | sv_to_dbt (&req->dbt1, key); |
1952 | sv_to_dbt (&req->dbt1, key); |
1525 | REQ_SEND; |
1953 | REQ_SEND; |
1526 | } |
1954 | } |
1527 | |
1955 | |
1528 | void |
1956 | void |
1529 | db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = &PL_sv_undef) |
1957 | db_sequence_close (DB_SEQUENCE *seq, U32 flags = 0, SV *callback = 0) |
|
|
1958 | PREINIT: |
|
|
1959 | CALLBACK |
1530 | CODE: |
1960 | CODE: |
1531 | { |
1961 | { |
1532 | dREQ (REQ_SEQ_CLOSE); |
1962 | dREQ (REQ_SEQ_CLOSE); |
1533 | req->seq = seq; |
1963 | req->seq = seq; |
1534 | req->uint1 = flags; |
1964 | req->uint1 = flags; |
1535 | REQ_SEND; |
1965 | REQ_SEND; |
1536 | ptr_nuke (ST (0)); |
1966 | ptr_nuke (ST (0)); |
1537 | } |
1967 | } |
1538 | |
1968 | |
1539 | void |
1969 | void |
1540 | db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = &PL_sv_undef) |
1970 | db_sequence_get (DB_SEQUENCE *seq, DB_TXN_ornull *txnid, int delta, SV *seq_value, U32 flags = DB_TXN_NOSYNC, SV *callback = 0) |
|
|
1971 | PREINIT: |
|
|
1972 | CALLBACK |
1541 | CODE: |
1973 | CODE: |
1542 | { |
1974 | { |
1543 | dREQ (REQ_SEQ_GET); |
1975 | dREQ (REQ_SEQ_GET); |
1544 | req->seq = seq; |
1976 | req->seq = seq; |
1545 | req->txn = txnid; |
1977 | req->txn = txnid; |
… | |
… | |
1548 | req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
1980 | req->sv1 = SvREFCNT_inc (seq_value); SvREADONLY_on (seq_value); |
1549 | REQ_SEND; |
1981 | REQ_SEND; |
1550 | } |
1982 | } |
1551 | |
1983 | |
1552 | void |
1984 | void |
1553 | db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = &PL_sv_undef) |
1985 | db_sequence_remove (DB_SEQUENCE *seq, DB_TXN_ornull *txnid = 0, U32 flags = 0, SV *callback = 0) |
|
|
1986 | PREINIT: |
|
|
1987 | CALLBACK |
1554 | CODE: |
1988 | CODE: |
1555 | { |
1989 | { |
1556 | dREQ (REQ_SEQ_REMOVE); |
1990 | dREQ (REQ_SEQ_REMOVE); |
1557 | req->seq = seq; |
1991 | req->seq = seq; |
1558 | req->txn = txnid; |
1992 | req->txn = txnid; |
1559 | req->uint1 = flags; |
1993 | req->uint1 = flags; |
1560 | REQ_SEND; |
1994 | REQ_SEND; |
1561 | } |
1995 | } |
1562 | |
1996 | |
|
|
1997 | #endif |
|
|
1998 | |
1563 | |
1999 | |
1564 | MODULE = BDB PACKAGE = BDB::Env |
2000 | MODULE = BDB PACKAGE = BDB::Env |
1565 | |
2001 | |
1566 | void |
2002 | void |
1567 | DESTROY (DB_ENV_ornull *env) |
2003 | DESTROY (DB_ENV_ornuked *env) |
1568 | CODE: |
2004 | CODE: |
1569 | if (env) |
2005 | if (env) |
1570 | env->close (env, 0); |
2006 | env->close (env, 0); |
1571 | |
2007 | |
1572 | int set_data_dir (DB_ENV *env, const char *dir) |
2008 | int set_data_dir (DB_ENV *env, const char *dir) |
… | |
… | |
1597 | CODE: |
2033 | CODE: |
1598 | RETVAL = env->set_cachesize (env, gbytes, bytes, ncache); |
2034 | RETVAL = env->set_cachesize (env, gbytes, bytes, ncache); |
1599 | OUTPUT: |
2035 | OUTPUT: |
1600 | RETVAL |
2036 | RETVAL |
1601 | |
2037 | |
1602 | int set_flags (DB_ENV *env, U32 flags, int onoff) |
2038 | int set_flags (DB_ENV *env, U32 flags, int onoff = 1) |
1603 | CODE: |
2039 | CODE: |
1604 | RETVAL = env->set_flags (env, flags, onoff); |
2040 | RETVAL = env->set_flags (env, flags, onoff); |
1605 | OUTPUT: |
2041 | OUTPUT: |
1606 | RETVAL |
2042 | RETVAL |
1607 | |
2043 | |
|
|
2044 | #if DB_VERSION_MINOR >= 7 |
|
|
2045 | |
|
|
2046 | int set_intermediate_dir_mode (DB_ENV *env, const char *mode) |
|
|
2047 | CODE: |
|
|
2048 | RETVAL = env->set_intermediate_dir_mode (env, mode); |
|
|
2049 | OUTPUT: |
|
|
2050 | RETVAL |
|
|
2051 | |
|
|
2052 | int log_set_config (DB_ENV *env, U32 flags, int onoff = 1) |
|
|
2053 | CODE: |
|
|
2054 | RETVAL = env->log_set_config (env, flags, onoff); |
|
|
2055 | OUTPUT: |
|
|
2056 | RETVAL |
|
|
2057 | |
|
|
2058 | #endif |
|
|
2059 | |
|
|
2060 | |
|
|
2061 | void set_errfile (DB_ENV *env, FILE *errfile = 0) |
|
|
2062 | CODE: |
|
|
2063 | env->set_errfile (env, errfile); |
|
|
2064 | |
|
|
2065 | void set_msgfile (DB_ENV *env, FILE *msgfile = 0) |
|
|
2066 | CODE: |
|
|
2067 | env->set_msgfile (env, msgfile); |
|
|
2068 | |
|
|
2069 | int set_verbose (DB_ENV *env, U32 which = -1, int onoff = 1) |
|
|
2070 | CODE: |
|
|
2071 | RETVAL = env->set_verbose (env, which, onoff); |
|
|
2072 | OUTPUT: |
|
|
2073 | RETVAL |
|
|
2074 | |
1608 | int set_encrypt (DB_ENV *env, const char *password, U32 flags = 0) |
2075 | int set_encrypt (DB_ENV *env, const char *password, U32 flags = 0) |
1609 | CODE: |
2076 | CODE: |
1610 | RETVAL = env->set_encrypt (env, password, flags); |
2077 | RETVAL = env->set_encrypt (env, password, flags); |
1611 | OUTPUT: |
2078 | OUTPUT: |
1612 | RETVAL |
2079 | RETVAL |
1613 | |
2080 | |
1614 | int set_timeout (DB_ENV *env, NV timeout, U32 flags) |
2081 | int set_timeout (DB_ENV *env, NV timeout, U32 flags = DB_SET_TXN_TIMEOUT) |
1615 | CODE: |
2082 | CODE: |
1616 | RETVAL = env->set_timeout (env, timeout * 1000000, flags); |
2083 | RETVAL = env->set_timeout (env, timeout * 1000000, flags); |
1617 | OUTPUT: |
2084 | OUTPUT: |
1618 | RETVAL |
2085 | RETVAL |
1619 | |
2086 | |
… | |
… | |
1633 | CODE: |
2100 | CODE: |
1634 | RETVAL = env->set_mp_mmapsize (env, ((size_t)mmapsize_mb) << 20); |
2101 | RETVAL = env->set_mp_mmapsize (env, ((size_t)mmapsize_mb) << 20); |
1635 | OUTPUT: |
2102 | OUTPUT: |
1636 | RETVAL |
2103 | RETVAL |
1637 | |
2104 | |
1638 | int set_lk_detect (DB_ENV *env, U32 detect) |
2105 | int set_lk_detect (DB_ENV *env, U32 detect = DB_LOCK_DEFAULT) |
1639 | CODE: |
2106 | CODE: |
1640 | RETVAL = env->set_lk_detect (env, detect); |
2107 | RETVAL = env->set_lk_detect (env, detect); |
1641 | OUTPUT: |
2108 | OUTPUT: |
1642 | RETVAL |
2109 | RETVAL |
1643 | |
2110 | |
… | |
… | |
1668 | int set_lg_max (DB_ENV *env, U32 max) |
2135 | int set_lg_max (DB_ENV *env, U32 max) |
1669 | CODE: |
2136 | CODE: |
1670 | RETVAL = env->set_lg_max (env, max); |
2137 | RETVAL = env->set_lg_max (env, max); |
1671 | OUTPUT: |
2138 | OUTPUT: |
1672 | RETVAL |
2139 | RETVAL |
|
|
2140 | |
|
|
2141 | #if DB_VERSION_MINOR >= 4 |
|
|
2142 | |
|
|
2143 | int mutex_set_max (DB_ENV *env, U32 max) |
|
|
2144 | CODE: |
|
|
2145 | RETVAL = env->mutex_set_max (env, max); |
|
|
2146 | OUTPUT: |
|
|
2147 | RETVAL |
|
|
2148 | |
|
|
2149 | int mutex_set_increment (DB_ENV *env, U32 increment) |
|
|
2150 | CODE: |
|
|
2151 | RETVAL = env->mutex_set_increment (env, increment); |
|
|
2152 | OUTPUT: |
|
|
2153 | RETVAL |
|
|
2154 | |
|
|
2155 | int mutex_set_tas_spins (DB_ENV *env, U32 tas_spins) |
|
|
2156 | CODE: |
|
|
2157 | RETVAL = env->mutex_set_tas_spins (env, tas_spins); |
|
|
2158 | OUTPUT: |
|
|
2159 | RETVAL |
|
|
2160 | |
|
|
2161 | int mutex_set_align (DB_ENV *env, U32 align) |
|
|
2162 | CODE: |
|
|
2163 | RETVAL = env->mutex_set_align (env, align); |
|
|
2164 | OUTPUT: |
|
|
2165 | RETVAL |
|
|
2166 | |
|
|
2167 | #endif |
1673 | |
2168 | |
1674 | DB_TXN * |
2169 | DB_TXN * |
1675 | txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0) |
2170 | txn_begin (DB_ENV *env, DB_TXN_ornull *parent = 0, U32 flags = 0) |
1676 | CODE: |
2171 | CODE: |
1677 | errno = env->txn_begin (env, parent, &RETVAL, flags); |
2172 | errno = env->txn_begin (env, parent, &RETVAL, flags); |
1678 | if (errno) |
2173 | if (errno) |
1679 | croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
2174 | croak ("DB_ENV->txn_begin: %s", db_strerror (errno)); |
1680 | OUTPUT: |
2175 | OUTPUT: |
1681 | RETVAL |
2176 | RETVAL |
1682 | |
2177 | |
|
|
2178 | #if DB_VERSION_MINOR >= 5 |
|
|
2179 | |
|
|
2180 | DB_TXN * |
|
|
2181 | cdsgroup_begin (DB_ENV *env) |
|
|
2182 | CODE: |
|
|
2183 | errno = env->cdsgroup_begin (env, &RETVAL); |
|
|
2184 | if (errno) |
|
|
2185 | croak ("DB_ENV->cdsgroup_begin: %s", db_strerror (errno)); |
|
|
2186 | OUTPUT: |
|
|
2187 | RETVAL |
|
|
2188 | |
|
|
2189 | #endif |
|
|
2190 | |
1683 | MODULE = BDB PACKAGE = BDB::Db |
2191 | MODULE = BDB PACKAGE = BDB::Db |
1684 | |
2192 | |
1685 | void |
2193 | void |
1686 | DESTROY (DB_ornull *db) |
2194 | DESTROY (DB_ornuked *db) |
1687 | CODE: |
2195 | CODE: |
1688 | if (db) |
2196 | if (db) |
1689 | { |
2197 | { |
1690 | SV *env = (SV *)db->app_private; |
2198 | SV *env = (SV *)db->app_private; |
1691 | db->close (db, 0); |
2199 | db->close (db, 0); |
… | |
… | |
1696 | CODE: |
2204 | CODE: |
1697 | RETVAL = db->set_cachesize (db, gbytes, bytes, ncache); |
2205 | RETVAL = db->set_cachesize (db, gbytes, bytes, ncache); |
1698 | OUTPUT: |
2206 | OUTPUT: |
1699 | RETVAL |
2207 | RETVAL |
1700 | |
2208 | |
1701 | int set_flags (DB *db, U32 flags); |
2209 | int set_flags (DB *db, U32 flags) |
1702 | CODE: |
2210 | CODE: |
1703 | RETVAL = db->set_flags (db, flags); |
2211 | RETVAL = db->set_flags (db, flags); |
1704 | OUTPUT: |
2212 | OUTPUT: |
1705 | RETVAL |
2213 | RETVAL |
1706 | |
2214 | |
… | |
… | |
1720 | CODE: |
2228 | CODE: |
1721 | RETVAL = db->set_bt_minkey (db, minkey); |
2229 | RETVAL = db->set_bt_minkey (db, minkey); |
1722 | OUTPUT: |
2230 | OUTPUT: |
1723 | RETVAL |
2231 | RETVAL |
1724 | |
2232 | |
1725 | int set_re_delim(DB *db, int delim); |
2233 | int set_re_delim (DB *db, int delim) |
1726 | CODE: |
2234 | CODE: |
1727 | RETVAL = db->set_re_delim (db, delim); |
2235 | RETVAL = db->set_re_delim (db, delim); |
1728 | OUTPUT: |
2236 | OUTPUT: |
1729 | RETVAL |
2237 | RETVAL |
1730 | |
2238 | |
… | |
… | |
1771 | if (errno) |
2279 | if (errno) |
1772 | croak ("DB->cursor: %s", db_strerror (errno)); |
2280 | croak ("DB->cursor: %s", db_strerror (errno)); |
1773 | OUTPUT: |
2281 | OUTPUT: |
1774 | RETVAL |
2282 | RETVAL |
1775 | |
2283 | |
|
|
2284 | #if DB_VERSION_MINOR >= 3 |
|
|
2285 | |
1776 | DB_SEQUENCE * |
2286 | DB_SEQUENCE * |
1777 | sequence (DB *db, U32 flags = 0) |
2287 | sequence (DB *db, U32 flags = 0) |
1778 | CODE: |
2288 | CODE: |
1779 | { |
2289 | { |
1780 | errno = db_sequence_create (&RETVAL, db, flags); |
2290 | errno = db_sequence_create (&RETVAL, db, flags); |
… | |
… | |
1782 | croak ("db_sequence_create: %s", db_strerror (errno)); |
2292 | croak ("db_sequence_create: %s", db_strerror (errno)); |
1783 | } |
2293 | } |
1784 | OUTPUT: |
2294 | OUTPUT: |
1785 | RETVAL |
2295 | RETVAL |
1786 | |
2296 | |
|
|
2297 | #endif |
|
|
2298 | |
1787 | |
2299 | |
1788 | MODULE = BDB PACKAGE = BDB::Txn |
2300 | MODULE = BDB PACKAGE = BDB::Txn |
1789 | |
2301 | |
1790 | void |
2302 | void |
1791 | DESTROY (DB_TXN_ornull *txn) |
2303 | DESTROY (DB_TXN_ornuked *txn) |
1792 | CODE: |
2304 | CODE: |
1793 | if (txn) |
2305 | if (txn) |
1794 | txn->abort (txn); |
2306 | txn->abort (txn); |
1795 | |
2307 | |
1796 | int set_timeout (DB_TXN *txn, NV timeout, U32 flags) |
2308 | int set_timeout (DB_TXN *txn, NV timeout, U32 flags = DB_SET_TXN_TIMEOUT) |
1797 | CODE: |
2309 | CODE: |
1798 | RETVAL = txn->set_timeout (txn, timeout * 1000000, flags); |
2310 | RETVAL = txn->set_timeout (txn, timeout * 1000000, flags); |
1799 | OUTPUT: |
2311 | OUTPUT: |
1800 | RETVAL |
2312 | RETVAL |
1801 | |
2313 | |
|
|
2314 | int failed (DB_TXN *txn) |
|
|
2315 | CODE: |
|
|
2316 | RETVAL = !!(txn->flags & TXN_DEADLOCK); |
|
|
2317 | OUTPUT: |
|
|
2318 | RETVAL |
|
|
2319 | |
1802 | |
2320 | |
1803 | MODULE = BDB PACKAGE = BDB::Cursor |
2321 | MODULE = BDB PACKAGE = BDB::Cursor |
1804 | |
2322 | |
1805 | void |
2323 | void |
1806 | DESTROY (DBC_ornull *dbc) |
2324 | DESTROY (DBC_ornuked *dbc) |
1807 | CODE: |
2325 | CODE: |
1808 | if (dbc) |
2326 | if (dbc) |
1809 | dbc->c_close (dbc); |
2327 | dbc->c_close (dbc); |
1810 | |
2328 | |
|
|
2329 | #if DB_VERSION_MINOR >= 6 |
|
|
2330 | |
|
|
2331 | int set_priority (DBC *dbc, int priority) |
|
|
2332 | CODE: |
|
|
2333 | dbc->set_priority (dbc, priority); |
|
|
2334 | |
|
|
2335 | #endif |
|
|
2336 | |
|
|
2337 | #if DB_VERSION_MINOR >= 3 |
|
|
2338 | |
1811 | MODULE = BDB PACKAGE = BDB::Sequence |
2339 | MODULE = BDB PACKAGE = BDB::Sequence |
1812 | |
2340 | |
1813 | void |
2341 | void |
1814 | DESTROY (DB_SEQUENCE_ornull *seq) |
2342 | DESTROY (DB_SEQUENCE_ornuked *seq) |
1815 | CODE: |
2343 | CODE: |
1816 | if (seq) |
2344 | if (seq) |
1817 | seq->close (seq, 0); |
2345 | seq->close (seq, 0); |
1818 | |
2346 | |
1819 | int initial_value (DB_SEQUENCE *seq, db_seq_t value) |
2347 | int initial_value (DB_SEQUENCE *seq, db_seq_t value) |
… | |
… | |
1838 | CODE: |
2366 | CODE: |
1839 | RETVAL = seq->set_range (seq, min, max); |
2367 | RETVAL = seq->set_range (seq, min, max); |
1840 | OUTPUT: |
2368 | OUTPUT: |
1841 | RETVAL |
2369 | RETVAL |
1842 | |
2370 | |
|
|
2371 | #endif |
|
|
2372 | |
|
|
2373 | |