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

Comparing BDB/BDB.xs (file contents):
Revision 1.18 by root, Sun Sep 16 18:15:34 2007 UTC vs.
Revision 1.19 by root, Mon Sep 24 18:14:11 2007 UTC

191} 191}
192 192
193static volatile unsigned int nreqs, nready, npending; 193static volatile unsigned int nreqs, nready, npending;
194static volatile unsigned int max_idle = 4; 194static volatile unsigned int max_idle = 4;
195static volatile unsigned int max_outstanding = 0xffffffff; 195static volatile unsigned int max_outstanding = 0xffffffff;
196static int respipe [2], respipe_osf [2]; 196static int respipe_osf [2], respipe [2] = { -1, -1 };
197 197
198static mutex_t reslock = X_MUTEX_INIT; 198static mutex_t reslock = X_MUTEX_INIT;
199static mutex_t reqlock = X_MUTEX_INIT; 199static mutex_t reqlock = X_MUTEX_INIT;
200static cond_t reqwait = X_COND_INIT; 200static cond_t reqwait = X_COND_INIT;
201 201
379#else 379#else
380# define TO_SOCKET(x) (x) 380# define TO_SOCKET(x) (x)
381#endif 381#endif
382 382
383static void 383static void
384create_pipe (int fd[2]) 384create_respipe ()
385{ 385{
386 int old_readfd = respipe [0];
387
388 if (respipe [1] >= 0)
389 respipe_close (TO_SOCKET (respipe [1]));
390
391#ifdef _WIN32
392 if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, respipe))
393#else
394 if (pipe (respipe))
395#endif
396 croak ("unable to initialize result pipe");
397
398 if (old_readfd >= 0)
399 {
400 if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0)
401 croak ("unable to initialize result pipe(2)");
402
403 respipe_close (respipe [0]);
404 respipe [0] = old_readfd;
405 }
406
386#ifdef _WIN32 407#ifdef _WIN32
387 int arg = 1; 408 int arg = 1;
388 if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, fd)
389 || ioctlsocket (TO_SOCKET (fd [0]), FIONBIO, &arg) 409 if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg)
390 || ioctlsocket (TO_SOCKET (fd [1]), FIONBIO, &arg)) 410 || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg))
391#else 411#else
392 if (pipe (fd)
393 || fcntl (fd [0], F_SETFL, O_NONBLOCK) 412 if (fcntl (respipe [0], F_SETFL, O_NONBLOCK)
394 || fcntl (fd [1], F_SETFL, O_NONBLOCK)) 413 || fcntl (respipe [1], F_SETFL, O_NONBLOCK))
395#endif 414#endif
396 croak ("unable to initialize result pipe"); 415 croak ("unable to initialize result pipe(3)");
397 416
398 respipe_osf [0] = TO_SOCKET (respipe [0]); 417 respipe_osf [0] = TO_SOCKET (respipe [0]);
399 respipe_osf [1] = TO_SOCKET (respipe [1]); 418 respipe_osf [1] = TO_SOCKET (respipe [1]);
400} 419}
401 420
867 idle = 0; 886 idle = 0;
868 nreqs = 0; 887 nreqs = 0;
869 nready = 0; 888 nready = 0;
870 npending = 0; 889 npending = 0;
871 890
872 respipe_close (respipe [0]);
873 respipe_close (respipe [1]);
874
875 create_pipe (respipe); 891 create_respipe ();
876 892
877 atfork_parent (); 893 atfork_parent ();
878} 894}
879 895
880#define dREQ(reqtype) \ 896#define dREQ(reqtype) \
1117 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); 1133 newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv));
1118 1134
1119 newCONSTSUB (stash, "DB_VERSION", newSVnv (DB_VERSION_MAJOR + DB_VERSION_MINOR * .1)); 1135 newCONSTSUB (stash, "DB_VERSION", newSVnv (DB_VERSION_MAJOR + DB_VERSION_MINOR * .1));
1120 newCONSTSUB (stash, "DB_VERSION_STRING", newSVpv (DB_VERSION_STRING, 0)); 1136 newCONSTSUB (stash, "DB_VERSION_STRING", newSVpv (DB_VERSION_STRING, 0));
1121 1137
1122 create_pipe (respipe); 1138 create_respipe ();
1123 1139
1124 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); 1140 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child);
1125#ifdef _WIN32 1141#ifdef _WIN32
1126 X_MUTEX_CHECK (wrklock); 1142 X_MUTEX_CHECK (wrklock);
1127 X_MUTEX_CHECK (reslock); 1143 X_MUTEX_CHECK (reslock);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines