… | |
… | |
64 | #endif |
64 | #endif |
65 | |
65 | |
66 | static char * |
66 | static char * |
67 | get_bdb_filename (SV *sv) |
67 | get_bdb_filename (SV *sv) |
68 | { |
68 | { |
69 | return !SvOK (sv) |
69 | if (!SvOK (sv)) |
70 | ? 0 |
70 | return 0; |
71 | : |
71 | |
72 | #if WIN32 |
72 | #if _WIN32 |
73 | SvPVutf8_nolen (sv) |
73 | /* win32 madness + win32 perl absolutely brokenness make for horrible hacks */ |
|
|
74 | { |
|
|
75 | STRLEN len; |
|
|
76 | char *src = SvPVbyte (sv, len); |
|
|
77 | SV *t1 = sv_newmortal (); |
|
|
78 | SV *t2 = sv_newmortal (); |
|
|
79 | |
|
|
80 | sv_upgrade (t1, SVt_PV); SvPOK_only (t1); SvGROW (t1, len * 16 + 1); |
|
|
81 | sv_upgrade (t2, SVt_PV); SvPOK_only (t2); SvGROW (t2, len * 16 + 1); |
|
|
82 | |
|
|
83 | len = MultiByteToWideChar (CP_ACP, 0, src, len, (WCHAR *)SvPVX (t1), SvLEN (t1) / sizeof (WCHAR)); |
|
|
84 | len = WideCharToMultiByte (CP_UTF8, 0, (WCHAR *)SvPVX (t1), len, SvPVX (t2), SvLEN (t2), 0, 0); |
|
|
85 | SvPOK_only (t2); |
|
|
86 | SvPVX (t2)[len] = 0; |
|
|
87 | SvCUR_set (t2, len); |
|
|
88 | |
|
|
89 | return SvPVX (t2); |
|
|
90 | } |
74 | #else |
91 | #else |
75 | SvPVbyte_nolen (sv) |
92 | return SvPVbyte_nolen (sv); |
76 | #endif |
93 | #endif |
77 | ; |
|
|
78 | } |
94 | } |
79 | |
95 | |
80 | static void |
96 | static void |
81 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
97 | debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) |
82 | { |
98 | { |
… | |
… | |
165 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
181 | NUM_PRI = PRI_MAX + PRI_BIAS + 1, |
166 | }; |
182 | }; |
167 | |
183 | |
168 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
184 | #define AIO_TICKS ((1000000 + 1023) >> 10) |
169 | |
185 | |
|
|
186 | static SV *on_next_submit; |
|
|
187 | |
170 | static unsigned int max_poll_time = 0; |
188 | static unsigned int max_poll_time = 0; |
171 | static unsigned int max_poll_reqs = 0; |
189 | static unsigned int max_poll_reqs = 0; |
172 | |
190 | |
173 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
191 | /* calculcate time difference in ~1/AIO_TICKS of a second */ |
174 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
192 | static int tvdiff (struct timeval *tv1, struct timeval *tv2) |
… | |
… | |
484 | } |
502 | } |
485 | |
503 | |
486 | static void req_send (bdb_req req) |
504 | static void req_send (bdb_req req) |
487 | { |
505 | { |
488 | SV *wait_callback = 0; |
506 | SV *wait_callback = 0; |
|
|
507 | |
|
|
508 | if (on_next_submit) |
|
|
509 | { |
|
|
510 | dSP; |
|
|
511 | SV *cb = sv_2mortal (on_next_submit); |
|
|
512 | |
|
|
513 | on_next_submit = 0; |
|
|
514 | |
|
|
515 | PUSHMARK (SP); |
|
|
516 | PUTBACK; |
|
|
517 | call_sv (cb, G_DISCARD | G_EVAL); |
|
|
518 | } |
489 | |
519 | |
490 | // synthesize callback if none given |
520 | // synthesize callback if none given |
491 | if (!SvOK (req->callback)) |
521 | if (!SvOK (req->callback)) |
492 | { |
522 | { |
493 | int count; |
523 | int count; |
… | |
… | |
1205 | newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1235 | newCONSTSUB (stash, "VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); |
1206 | |
1236 | |
1207 | create_respipe (); |
1237 | create_respipe (); |
1208 | |
1238 | |
1209 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1239 | X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); |
1210 | #ifdef _WIN32 |
|
|
1211 | X_MUTEX_CHECK (wrklock); |
|
|
1212 | X_MUTEX_CHECK (reslock); |
|
|
1213 | X_MUTEX_CHECK (reqlock); |
|
|
1214 | |
|
|
1215 | X_COND_CHECK (reqwait); |
|
|
1216 | #endif |
|
|
1217 | patch_errno (); |
1240 | patch_errno (); |
1218 | } |
1241 | } |
1219 | |
1242 | |
1220 | void |
1243 | void |
1221 | max_poll_reqs (int nreqs) |
1244 | max_poll_reqs (int nreqs) |
… | |
… | |
1361 | PROTOTYPE: ;$ |
1384 | PROTOTYPE: ;$ |
1362 | CODE: |
1385 | CODE: |
1363 | RETVAL = db_strerror (errorno); |
1386 | RETVAL = db_strerror (errorno); |
1364 | OUTPUT: |
1387 | OUTPUT: |
1365 | RETVAL |
1388 | RETVAL |
|
|
1389 | |
|
|
1390 | void _on_next_submit (SV *cb) |
|
|
1391 | CODE: |
|
|
1392 | SvREFCNT_dec (on_next_submit); |
|
|
1393 | on_next_submit = SvOK (cb) ? newSVsv (cb) : 0; |
1366 | |
1394 | |
1367 | DB_ENV * |
1395 | DB_ENV * |
1368 | db_env_create (U32 env_flags = 0) |
1396 | db_env_create (U32 env_flags = 0) |
1369 | CODE: |
1397 | CODE: |
1370 | { |
1398 | { |