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

Comparing IO-AIO/AIO.xs (file contents):
Revision 1.105 by root, Sun Jul 8 11:12:15 2007 UTC vs.
Revision 1.106 by root, Mon Sep 24 18:14:00 2007 UTC

264} 264}
265 265
266static volatile unsigned int nreqs, nready, npending; 266static volatile unsigned int nreqs, nready, npending;
267static volatile unsigned int max_idle = 4; 267static volatile unsigned int max_idle = 4;
268static volatile unsigned int max_outstanding = 0xffffffff; 268static volatile unsigned int max_outstanding = 0xffffffff;
269static int respipe [2], respipe_osf [2]; 269static int respipe_osf [2], respipe [2] = { -1, -1 };
270 270
271static mutex_t reslock = X_MUTEX_INIT; 271static mutex_t reslock = X_MUTEX_INIT;
272static mutex_t reqlock = X_MUTEX_INIT; 272static mutex_t reqlock = X_MUTEX_INIT;
273static cond_t reqwait = X_COND_INIT; 273static cond_t reqwait = X_COND_INIT;
274 274
634#else 634#else
635# define TO_SOCKET(x) (x) 635# define TO_SOCKET(x) (x)
636#endif 636#endif
637 637
638static void 638static void
639create_pipe (int fd[2]) 639create_respipe ()
640{ 640{
641 int old_readfd = respipe [0];
642
643 if (respipe [1] >= 0)
644 respipe_close (TO_SOCKET (respipe [1]));
645
646#ifdef _WIN32
647 if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, respipe))
648#else
649 if (pipe (respipe))
650#endif
651 croak ("unable to initialize result pipe");
652
653 if (old_readfd >= 0)
654 {
655 if (dup2 (TO_SOCKET (respipe [0]), TO_SOCKET (old_readfd)) < 0)
656 croak ("unable to initialize result pipe(2)");
657
658 respipe_close (respipe [0]);
659 respipe [0] = old_readfd;
660 }
661
641#ifdef _WIN32 662#ifdef _WIN32
642 int arg = 1; 663 int arg = 1;
643 if (PerlSock_socketpair (AF_UNIX, SOCK_STREAM, 0, fd)
644 || ioctlsocket (TO_SOCKET (fd [0]), FIONBIO, &arg) 664 if (ioctlsocket (TO_SOCKET (respipe [0]), FIONBIO, &arg)
645 || ioctlsocket (TO_SOCKET (fd [1]), FIONBIO, &arg)) 665 || ioctlsocket (TO_SOCKET (respipe [1]), FIONBIO, &arg))
646#else 666#else
647 if (pipe (fd)
648 || fcntl (fd [0], F_SETFL, O_NONBLOCK) 667 if (fcntl (respipe [0], F_SETFL, O_NONBLOCK)
649 || fcntl (fd [1], F_SETFL, O_NONBLOCK)) 668 || fcntl (respipe [1], F_SETFL, O_NONBLOCK))
650#endif 669#endif
651 croak ("unable to initialize result pipe"); 670 croak ("unable to initialize result pipe(3)");
652 671
653 respipe_osf [0] = TO_SOCKET (respipe [0]); 672 respipe_osf [0] = TO_SOCKET (respipe [0]);
654 respipe_osf [1] = TO_SOCKET (respipe [1]); 673 respipe_osf [1] = TO_SOCKET (respipe [1]);
655} 674}
656 675
1370 idle = 0; 1389 idle = 0;
1371 nreqs = 0; 1390 nreqs = 0;
1372 nready = 0; 1391 nready = 0;
1373 npending = 0; 1392 npending = 0;
1374 1393
1375 respipe_close (respipe [0]);
1376 respipe_close (respipe [1]);
1377
1378 create_pipe (respipe); 1394 create_respipe ();
1379 1395
1380 atfork_parent (); 1396 atfork_parent ();
1381} 1397}
1382 1398
1383#define dREQ \ 1399#define dREQ \
1426#else 1442#else
1427 newCONSTSUB (stash, "S_IFIFO", newSViv (S_IFIFO)); 1443 newCONSTSUB (stash, "S_IFIFO", newSViv (S_IFIFO));
1428 newCONSTSUB (stash, "SIGIO", newSViv (SIGIO)); 1444 newCONSTSUB (stash, "SIGIO", newSViv (SIGIO));
1429#endif 1445#endif
1430 1446
1431 create_pipe (respipe); 1447 create_respipe ();
1432 1448
1433 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child); 1449 X_THREAD_ATFORK (atfork_prepare, atfork_parent, atfork_child);
1434} 1450}
1435 1451
1436void 1452void

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines