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