ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/BDB/BDB.xs
(Generate patch)

Comparing BDB/BDB.xs (file contents):
Revision 1.35 by root, Sun Mar 30 07:12:12 2008 UTC vs.
Revision 1.38 by root, Wed May 21 19:13:43 2008 UTC

64#endif 64#endif
65 65
66static char * 66static char *
67get_bdb_filename (SV *sv) 67get_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
80static void 96static void
81debug_errcall (const DB_ENV *dbenv, const char *errpfx, const char *msg) 97debug_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
186static SV *on_next_submit;
187
170static unsigned int max_poll_time = 0; 188static unsigned int max_poll_time = 0;
171static unsigned int max_poll_reqs = 0; 189static 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 */
174static int tvdiff (struct timeval *tv1, struct timeval *tv2) 192static int tvdiff (struct timeval *tv1, struct timeval *tv2)
484} 502}
485 503
486static void req_send (bdb_req req) 504static 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
1220void 1243void
1221max_poll_reqs (int nreqs) 1244max_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
1390void _on_next_submit (SV *cb)
1391 CODE:
1392 SvREFCNT_dec (on_next_submit);
1393 on_next_submit = SvOK (cb) ? newSVsv (cb) : 0;
1366 1394
1367DB_ENV * 1395DB_ENV *
1368db_env_create (U32 env_flags = 0) 1396db_env_create (U32 env_flags = 0)
1369 CODE: 1397 CODE:
1370{ 1398{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines