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.68 by root, Tue Oct 24 03:40:25 2006 UTC vs.
Revision 1.71 by root, Tue Oct 24 16:35:04 2006 UTC

1/* solaris */
2#define _POSIX_PTHREAD_SEMANTICS 1
3
1#if __linux 4#if __linux
2# define _GNU_SOURCE 5# define _GNU_SOURCE
3#endif 6#endif
4 7
5#define _REENTRANT 1 8#define _REENTRANT 1
56 59
57/* buffer size for various temporary buffers */ 60/* buffer size for various temporary buffers */
58#define AIO_BUFSIZE 65536 61#define AIO_BUFSIZE 65536
59 62
60#define dBUF \ 63#define dBUF \
64 char *aio_buf; \
65 LOCK (wrklock); \
61 char *aio_buf = malloc (AIO_BUFSIZE); \ 66 self->dbuf = aio_buf = malloc (AIO_BUFSIZE); \
67 UNLOCK (wrklock); \
62 if (!aio_buf) \ 68 if (!aio_buf) \
63 return -1; 69 return -1;
64
65#define fBUF free (aio_buf)
66 70
67enum { 71enum {
68 REQ_QUIT, 72 REQ_QUIT,
69 REQ_OPEN, REQ_CLOSE, 73 REQ_OPEN, REQ_CLOSE,
70 REQ_READ, REQ_WRITE, REQ_READAHEAD, 74 REQ_READ, REQ_WRITE, REQ_READAHEAD,
73 REQ_FSYNC, REQ_FDATASYNC, 77 REQ_FSYNC, REQ_FDATASYNC,
74 REQ_UNLINK, REQ_RMDIR, REQ_RENAME, 78 REQ_UNLINK, REQ_RMDIR, REQ_RENAME,
75 REQ_READDIR, 79 REQ_READDIR,
76 REQ_LINK, REQ_SYMLINK, 80 REQ_LINK, REQ_SYMLINK,
77 REQ_GROUP, REQ_NOP, 81 REQ_GROUP, REQ_NOP,
78 REQ_SLEEP, 82 REQ_BUSY,
79}; 83};
80 84
81#define AIO_REQ_KLASS "IO::AIO::REQ" 85#define AIO_REQ_KLASS "IO::AIO::REQ"
82#define AIO_GRP_KLASS "IO::AIO::GRP" 86#define AIO_GRP_KLASS "IO::AIO::GRP"
83 87
132#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP) 136#if __linux && defined (PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP)
133# define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 137# define AIO_MUTEX_INIT PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
134#else 138#else
135# define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER 139# define AIO_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER
136#endif 140#endif
141
142#define LOCK(mutex) pthread_mutex_lock (&(mutex))
143#define UNLOCK(mutex) pthread_mutex_unlock (&(mutex))
144
145/* worker threasd management */
146static pthread_mutex_t wrklock = AIO_MUTEX_INIT;
147
148typedef struct worker {
149 /* locked by wrklock */
150 struct worker *prev, *next;
151
152 pthread_t tid;
153
154 /* locked by reslock, reqlock or wrklock */
155 aio_req req; /* currently processed request */
156 void *dbuf;
157 DIR *dirp;
158} worker;
159
160static worker wrk_first = { &wrk_first, &wrk_first, 0 };
161
162static void worker_clear (worker *wrk)
163{
164 if (wrk->dirp)
165 {
166 closedir (wrk->dirp);
167 wrk->dirp = 0;
168 }
169
170 if (wrk->dbuf)
171 {
172 free (wrk->dbuf);
173 wrk->dbuf = 0;
174 }
175}
176
177static void worker_free (worker *wrk)
178{
179 wrk->next->prev = wrk->prev;
180 wrk->prev->next = wrk->next;
181
182 free (wrk);
183}
137 184
138static pthread_mutex_t reslock = AIO_MUTEX_INIT; 185static pthread_mutex_t reslock = AIO_MUTEX_INIT;
139static pthread_mutex_t reqlock = AIO_MUTEX_INIT; 186static pthread_mutex_t reqlock = AIO_MUTEX_INIT;
140static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER; 187static pthread_cond_t reqwait = PTHREAD_COND_INITIALIZER;
141 188
271 fd_set rfd; 318 fd_set rfd;
272 319
273 while (nreqs) 320 while (nreqs)
274 { 321 {
275 int size; 322 int size;
276#if !(__i386 || __x86_64) /* safe without sempahore on this archs */ 323#if !(__i386 || __x86_64) /* safe without sempahore on these archs */
277 pthread_mutex_lock (&reslock); 324 LOCK (reslock);
278#endif 325#endif
279 size = res_queue.size; 326 size = res_queue.size;
280#if !(__i386 || __x86_64) /* safe without sempahore on this archs */ 327#if !(__i386 || __x86_64) /* safe without sempahore on these archs */
281 pthread_mutex_unlock (&reslock); 328 UNLOCK (reslock);
282#endif 329#endif
283 330
284 if (size) 331 if (size)
285 return; 332 return;
286 333
310 { 357 {
311 SV *rv = &PL_sv_undef; 358 SV *rv = &PL_sv_undef;
312 359
313 if (req->result >= 0) 360 if (req->result >= 0)
314 { 361 {
362 int i;
315 char *buf = req->data2ptr; 363 char *buf = req->data2ptr;
316 AV *av = newAV (); 364 AV *av = newAV ();
317 365
318 while (req->result) 366 av_extend (av, req->result - 1);
367
368 for (i = 0; i < req->result; ++i)
319 { 369 {
320 SV *sv = newSVpv (buf, 0); 370 SV *sv = newSVpv (buf, 0);
321 371
322 av_push (av, sv); 372 av_store (av, i, sv);
323 buf += SvCUR (sv) + 1; 373 buf += SvCUR (sv) + 1;
324 req->result--;
325 } 374 }
326 375
327 rv = sv_2mortal (newRV_noinc ((SV *)av)); 376 rv = sv_2mortal (newRV_noinc ((SV *)av));
328 } 377 }
329 378
361 PUSHs (*av_fetch (av, i, 0)); 410 PUSHs (*av_fetch (av, i, 0));
362 } 411 }
363 break; 412 break;
364 413
365 case REQ_NOP: 414 case REQ_NOP:
366 case REQ_SLEEP: 415 case REQ_BUSY:
367 break; 416 break;
368 417
369 default: 418 default:
370 PUSHs (sv_2mortal (newSViv (req->result))); 419 PUSHs (sv_2mortal (newSViv (req->result)));
371 break; 420 break;
413 SvREFCNT_dec (req->fh); 462 SvREFCNT_dec (req->fh);
414 SvREFCNT_dec (req->fh2); 463 SvREFCNT_dec (req->fh2);
415 SvREFCNT_dec (req->callback); 464 SvREFCNT_dec (req->callback);
416 Safefree (req->statdata); 465 Safefree (req->statdata);
417 466
418 if (req->type == REQ_READDIR && req->result >= 0) 467 if (req->type == REQ_READDIR)
419 free (req->data2ptr); 468 free (req->data2ptr);
420 469
421 Safefree (req); 470 Safefree (req);
422} 471}
423 472
441 int do_croak = 0; 490 int do_croak = 0;
442 aio_req req; 491 aio_req req;
443 492
444 for (;;) 493 for (;;)
445 { 494 {
446 pthread_mutex_lock (&reslock); 495 LOCK (reslock);
447 req = reqq_shift (&res_queue); 496 req = reqq_shift (&res_queue);
448 497
449 if (req) 498 if (req)
450 { 499 {
451 if (!res_queue.size) 500 if (!res_queue.size)
455 while (read (respipe [0], buf, 32) == 32) 504 while (read (respipe [0], buf, 32) == 32)
456 ; 505 ;
457 } 506 }
458 } 507 }
459 508
460 pthread_mutex_unlock (&reslock); 509 UNLOCK (reslock);
461 510
462 if (!req) 511 if (!req)
463 break; 512 break;
464 513
465 --nreqs; 514 --nreqs;
499 548
500static void *aio_proc(void *arg); 549static void *aio_proc(void *arg);
501 550
502static void start_thread (void) 551static void start_thread (void)
503{ 552{
553 worker *wrk = calloc (1, sizeof (worker));
554
555 if (!wrk)
556 croak ("unable to allocate worker thread data");
557
504 sigset_t fullsigset, oldsigset; 558 sigset_t fullsigset, oldsigset;
505 pthread_t tid;
506 pthread_attr_t attr; 559 pthread_attr_t attr;
507 560
508 pthread_attr_init (&attr); 561 pthread_attr_init (&attr);
509 pthread_attr_setstacksize (&attr, STACKSIZE); 562 pthread_attr_setstacksize (&attr, STACKSIZE);
510 pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); 563 pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
511 564
512 sigfillset (&fullsigset); 565 sigfillset (&fullsigset);
566
567 LOCK (wrklock);
513 sigprocmask (SIG_SETMASK, &fullsigset, &oldsigset); 568 sigprocmask (SIG_SETMASK, &fullsigset, &oldsigset);
514 569
515 if (pthread_create (&tid, &attr, aio_proc, 0) == 0) 570 if (pthread_create (&wrk->tid, &attr, aio_proc, (void *)wrk) == 0)
571 {
572 wrk->prev = &wrk_first;
573 wrk->next = wrk_first.next;
574 wrk_first.next->prev = wrk;
575 wrk_first.next = wrk;
516 started++; 576 started++;
577 }
578 else
579 free (wrk);
517 580
518 sigprocmask (SIG_SETMASK, &oldsigset, 0); 581 sigprocmask (SIG_SETMASK, &oldsigset, 0);
582 UNLOCK (wrklock);
519} 583}
520 584
521static void req_send (aio_req req) 585static void req_send (aio_req req)
522{ 586{
523 while (started < wanted && nreqs >= started) 587 while (started < wanted && nreqs >= started)
524 start_thread (); 588 start_thread ();
525 589
526 ++nreqs; 590 ++nreqs;
527 591
528 pthread_mutex_lock (&reqlock); 592 LOCK (reqlock);
529 reqq_push (&req_queue, req); 593 reqq_push (&req_queue, req);
530 pthread_cond_signal (&reqwait); 594 pthread_cond_signal (&reqwait);
531 pthread_mutex_unlock (&reqlock); 595 UNLOCK (reqlock);
532 596
533 if (nreqs > max_outstanding) 597 if (nreqs > max_outstanding)
534 for (;;) 598 for (;;)
535 { 599 {
536 poll_cb (); 600 poll_cb ();
609static ssize_t pread (int fd, void *buf, size_t count, off_t offset) 673static ssize_t pread (int fd, void *buf, size_t count, off_t offset)
610{ 674{
611 ssize_t res; 675 ssize_t res;
612 off_t ooffset; 676 off_t ooffset;
613 677
614 pthread_mutex_lock (&preadwritelock); 678 LOCK (preadwritelock);
615 ooffset = lseek (fd, 0, SEEK_CUR); 679 ooffset = lseek (fd, 0, SEEK_CUR);
616 lseek (fd, offset, SEEK_SET); 680 lseek (fd, offset, SEEK_SET);
617 res = read (fd, buf, count); 681 res = read (fd, buf, count);
618 lseek (fd, ooffset, SEEK_SET); 682 lseek (fd, ooffset, SEEK_SET);
619 pthread_mutex_unlock (&preadwritelock); 683 UNLOCK (preadwritelock);
620 684
621 return res; 685 return res;
622} 686}
623 687
624static ssize_t pwrite (int fd, void *buf, size_t count, off_t offset) 688static ssize_t pwrite (int fd, void *buf, size_t count, off_t offset)
625{ 689{
626 ssize_t res; 690 ssize_t res;
627 off_t ooffset; 691 off_t ooffset;
628 692
629 pthread_mutex_lock (&preadwritelock); 693 LOCK (preadwritelock);
630 ooffset = lseek (fd, 0, SEEK_CUR); 694 ooffset = lseek (fd, 0, SEEK_CUR);
631 lseek (fd, offset, SEEK_SET); 695 lseek (fd, offset, SEEK_SET);
632 res = write (fd, buf, count); 696 res = write (fd, buf, count);
633 lseek (fd, offset, SEEK_SET); 697 lseek (fd, offset, SEEK_SET);
634 pthread_mutex_unlock (&preadwritelock); 698 UNLOCK (preadwritelock);
635 699
636 return res; 700 return res;
637} 701}
638#endif 702#endif
639 703
655 pread (fd, aio_buf, len, offset); 719 pread (fd, aio_buf, len, offset);
656 offset += len; 720 offset += len;
657 count -= len; 721 count -= len;
658 } 722 }
659 723
660 fBUF;
661
662 errno = 0; 724 errno = 0;
663} 725}
664#endif 726#endif
665 727
666#if !HAVE_READDIR_R 728#if !HAVE_READDIR_R
671static int readdir_r (DIR *dirp, struct dirent *ent, struct dirent **res) 733static int readdir_r (DIR *dirp, struct dirent *ent, struct dirent **res)
672{ 734{
673 struct dirent *e; 735 struct dirent *e;
674 int errorno; 736 int errorno;
675 737
676 pthread_mutex_lock (&readdirlock); 738 LOCK (readdirlock);
677 739
678 e = readdir (dirp); 740 e = readdir (dirp);
679 errorno = errno; 741 errorno = errno;
680 742
681 if (e) 743 if (e)
684 strcpy (ent->d_name, e->d_name); 746 strcpy (ent->d_name, e->d_name);
685 } 747 }
686 else 748 else
687 *res = 0; 749 *res = 0;
688 750
689 pthread_mutex_unlock (&readdirlock); 751 UNLOCK (readdirlock);
690 752
691 errno = errorno; 753 errno = errorno;
692 return e ? 0 : -1; 754 return e ? 0 : -1;
693} 755}
694#endif 756#endif
695 757
696/* sendfile always needs emulation */ 758/* sendfile always needs emulation */
697static ssize_t sendfile_ (int ofd, int ifd, off_t offset, size_t count) 759static ssize_t sendfile_ (int ofd, int ifd, off_t offset, size_t count, worker *self)
698{ 760{
699 ssize_t res; 761 ssize_t res;
700 762
701 if (!count) 763 if (!count)
702 return 0; 764 return 0;
779 841
780 offset += cnt; 842 offset += cnt;
781 res += cnt; 843 res += cnt;
782 count -= cnt; 844 count -= cnt;
783 } 845 }
784
785 fBUF;
786 } 846 }
787 847
788 return res; 848 return res;
789} 849}
790 850
791/* read a full directory */ 851/* read a full directory */
792static int scandir_ (const char *path, void **namesp) 852static void scandir_ (aio_req req, worker *self)
793{ 853{
794 DIR *dirp; 854 DIR *dirp;
795 union 855 union
796 { 856 {
797 struct dirent d; 857 struct dirent d;
802 int memlen = 4096; 862 int memlen = 4096;
803 int memofs = 0; 863 int memofs = 0;
804 int res = 0; 864 int res = 0;
805 int errorno; 865 int errorno;
806 866
807 dirp = opendir (path); 867 LOCK (wrklock);
808 if (!dirp) 868 self->dirp = dirp = opendir (req->dataptr);
809 return -1;
810
811 u = malloc (sizeof (*u)); 869 self->dbuf = u = malloc (sizeof (*u));
870 UNLOCK (wrklock);
871
812 names = malloc (memlen); 872 req->data2ptr = names = malloc (memlen);
813 873
814 if (u && names) 874 if (dirp && u && names)
815 for (;;) 875 for (;;)
816 { 876 {
817 errno = 0; 877 errno = 0;
818 readdir_r (dirp, &u->d, &entp); 878 readdir_r (dirp, &u->d, &entp);
819 879
829 res++; 889 res++;
830 890
831 while (memofs + len > memlen) 891 while (memofs + len > memlen)
832 { 892 {
833 memlen *= 2; 893 memlen *= 2;
894 LOCK (wrklock);
834 names = realloc (names, memlen); 895 req->data2ptr = names = realloc (names, memlen);
896 UNLOCK (wrklock);
897
835 if (!names) 898 if (!names)
836 break; 899 break;
837 } 900 }
838 901
839 memcpy (names + memofs, name, len); 902 memcpy (names + memofs, name, len);
840 memofs += len; 903 memofs += len;
841 } 904 }
842 } 905 }
843 906
844 errorno = errno;
845 free (u);
846 closedir (dirp);
847
848 if (errorno) 907 if (errno)
849 {
850 free (names);
851 errno = errorno;
852 res = -1; 908 res = -1;
853 } 909
854 910 req->result = res;
855 *namesp = (void *)names;
856 return res;
857} 911}
858 912
859/*****************************************************************************/ 913/*****************************************************************************/
860 914
861static void *aio_proc (void *thr_arg) 915static void *aio_proc (void *thr_arg)
862{ 916{
863 aio_req req; 917 aio_req req;
864 int type; 918 int type;
919 worker *self = (worker *)thr_arg;
865 920
866 do 921 do
867 { 922 {
868 pthread_mutex_lock (&reqlock); 923 LOCK (reqlock);
869 924
870 for (;;) 925 for (;;)
871 { 926 {
872 req = reqq_shift (&req_queue); 927 self->req = req = reqq_shift (&req_queue);
873 928
874 if (req) 929 if (req)
875 break; 930 break;
876 931
877 pthread_cond_wait (&reqwait, &reqlock); 932 pthread_cond_wait (&reqwait, &reqlock);
878 } 933 }
879 934
880 pthread_mutex_unlock (&reqlock); 935 UNLOCK (reqlock);
881 936
882 errno = 0; /* strictly unnecessary */ 937 errno = 0; /* strictly unnecessary */
883 type = req->type; /* remember type for QUIT check */ 938 type = req->type; /* remember type for QUIT check */
884 939
885 if (!(req->flags & FLAG_CANCELLED)) 940 if (!(req->flags & FLAG_CANCELLED))
887 { 942 {
888 case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break; 943 case REQ_READ: req->result = pread (req->fd, req->dataptr, req->length, req->offset); break;
889 case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break; 944 case REQ_WRITE: req->result = pwrite (req->fd, req->dataptr, req->length, req->offset); break;
890 945
891 case REQ_READAHEAD: req->result = readahead (req->fd, req->offset, req->length); break; 946 case REQ_READAHEAD: req->result = readahead (req->fd, req->offset, req->length); break;
892 case REQ_SENDFILE: req->result = sendfile_ (req->fd, req->fd2, req->offset, req->length); break; 947 case REQ_SENDFILE: req->result = sendfile_ (req->fd, req->fd2, req->offset, req->length, self); break;
893 948
894 case REQ_STAT: req->result = stat (req->dataptr, req->statdata); break; 949 case REQ_STAT: req->result = stat (req->dataptr, req->statdata); break;
895 case REQ_LSTAT: req->result = lstat (req->dataptr, req->statdata); break; 950 case REQ_LSTAT: req->result = lstat (req->dataptr, req->statdata); break;
896 case REQ_FSTAT: req->result = fstat (req->fd , req->statdata); break; 951 case REQ_FSTAT: req->result = fstat (req->fd , req->statdata); break;
897 952
903 case REQ_LINK: req->result = link (req->data2ptr, req->dataptr); break; 958 case REQ_LINK: req->result = link (req->data2ptr, req->dataptr); break;
904 case REQ_SYMLINK: req->result = symlink (req->data2ptr, req->dataptr); break; 959 case REQ_SYMLINK: req->result = symlink (req->data2ptr, req->dataptr); break;
905 960
906 case REQ_FDATASYNC: req->result = fdatasync (req->fd); break; 961 case REQ_FDATASYNC: req->result = fdatasync (req->fd); break;
907 case REQ_FSYNC: req->result = fsync (req->fd); break; 962 case REQ_FSYNC: req->result = fsync (req->fd); break;
908 case REQ_READDIR: req->result = scandir_ (req->dataptr, &req->data2ptr); break; 963 case REQ_READDIR: scandir_ (req, self); break;
909 964
910 case REQ_SLEEP: 965 case REQ_BUSY:
911 { 966 {
912 struct timeval tv; 967 struct timeval tv;
913 968
914 tv.tv_sec = req->fd; 969 tv.tv_sec = req->fd;
915 tv.tv_usec = req->fd2; 970 tv.tv_usec = req->fd2;
927 break; 982 break;
928 } 983 }
929 984
930 req->errorno = errno; 985 req->errorno = errno;
931 986
932 pthread_mutex_lock (&reslock); 987 LOCK (reslock);
933 988
934 if (!reqq_push (&res_queue, req)) 989 if (!reqq_push (&res_queue, req))
935 /* write a dummy byte to the pipe so fh becomes ready */ 990 /* write a dummy byte to the pipe so fh becomes ready */
936 write (respipe [1], &respipe, 1); 991 write (respipe [1], &respipe, 1);
937 992
938 pthread_mutex_unlock (&reslock); 993 self->req = 0;
994 worker_clear (self);
995
996 UNLOCK (reslock);
939 } 997 }
940 while (type != REQ_QUIT); 998 while (type != REQ_QUIT);
941 999
1000 LOCK (wrklock);
1001 worker_free (self);
1002 UNLOCK (wrklock);
1003
942 return 0; 1004 return 0;
943} 1005}
944 1006
945/*****************************************************************************/ 1007/*****************************************************************************/
946 1008
947static void atfork_prepare (void) 1009static void atfork_prepare (void)
948{ 1010{
949 pthread_mutex_lock (&reqlock); 1011 LOCK (wrklock);
950 pthread_mutex_lock (&reslock); 1012 LOCK (reqlock);
1013 LOCK (reslock);
951#if !HAVE_PREADWRITE 1014#if !HAVE_PREADWRITE
952 pthread_mutex_lock (&preadwritelock); 1015 LOCK (preadwritelock);
953#endif 1016#endif
954#if !HAVE_READDIR_R 1017#if !HAVE_READDIR_R
955 pthread_mutex_lock (&readdirlock); 1018 LOCK (readdirlock);
956#endif 1019#endif
957} 1020}
958 1021
959static void atfork_parent (void) 1022static void atfork_parent (void)
960{ 1023{
961#if !HAVE_READDIR_R 1024#if !HAVE_READDIR_R
962 pthread_mutex_unlock (&readdirlock); 1025 UNLOCK (readdirlock);
963#endif 1026#endif
964#if !HAVE_PREADWRITE 1027#if !HAVE_PREADWRITE
965 pthread_mutex_unlock (&preadwritelock); 1028 UNLOCK (preadwritelock);
966#endif 1029#endif
967 pthread_mutex_unlock (&reslock); 1030 UNLOCK (reslock);
968 pthread_mutex_unlock (&reqlock); 1031 UNLOCK (reqlock);
1032 UNLOCK (wrklock);
969} 1033}
970 1034
971static void atfork_child (void) 1035static void atfork_child (void)
972{ 1036{
973 aio_req prv; 1037 aio_req prv;
974
975 started = 0;
976 1038
977 while (prv = reqq_shift (&req_queue)) 1039 while (prv = reqq_shift (&req_queue))
978 req_free (prv); 1040 req_free (prv);
979 1041
980 while (prv = reqq_shift (&res_queue)) 1042 while (prv = reqq_shift (&res_queue))
981 req_free (prv); 1043 req_free (prv);
982 1044
1045 while (wrk_first.next != &wrk_first)
1046 {
1047 worker *wrk = wrk_first.next;
1048
1049 if (wrk->req)
1050 req_free (wrk->req);
1051
1052 worker_clear (wrk);
1053 worker_free (wrk);
1054 }
1055
1056 started = 0;
1057 nreqs = 0;
1058
983 close (respipe [0]); 1059 close (respipe [0]);
984 close (respipe [1]); 1060 close (respipe [1]);
985 create_pipe (); 1061 create_pipe ();
986 1062
987 atfork_parent (); 1063 atfork_parent ();
1262 1338
1263 REQ_SEND; 1339 REQ_SEND;
1264} 1340}
1265 1341
1266void 1342void
1267aio_sleep (delay,callback=&PL_sv_undef) 1343aio_busy (delay,callback=&PL_sv_undef)
1268 double delay 1344 double delay
1269 SV * callback 1345 SV * callback
1270 PPCODE: 1346 PPCODE:
1271{ 1347{
1272 dREQ; 1348 dREQ;
1273 1349
1274 req->type = REQ_SLEEP; 1350 req->type = REQ_BUSY;
1275 req->fd = delay < 0. ? 0 : delay; 1351 req->fd = delay < 0. ? 0 : delay;
1276 req->fd2 = delay < 0. ? 0 : 1000. * (delay - req->fd); 1352 req->fd2 = delay < 0. ? 0 : 1000. * (delay - req->fd);
1277 1353
1278 REQ_SEND; 1354 REQ_SEND;
1279} 1355}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines