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.37 by root, Tue Aug 23 12:37:19 2005 UTC vs.
Revision 1.39 by root, Mon Feb 6 23:54:12 2006 UTC

31# else 31# else
32# error sendfile support requested but not available 32# error sendfile support requested but not available
33# endif 33# endif
34#endif 34#endif
35 35
36/* used for struct dirent, AIX doesn't provide it */
37#ifndef NAME_MAX
38# define NAME_MAX 4096
39#endif
40
36#if __ia64 41#if __ia64
37# define STACKSIZE 65536 42# define STACKSIZE 65536
38#else 43#else
39# define STACKSIZE 8192 44# define STACKSIZE 8192
40#endif 45#endif
499 504
500 if (res < 0 && sbytes) 505 if (res < 0 && sbytes)
501 res = sbytes; 506 res = sbytes;
502 } 507 }
503 508
509# endif
504# else 510#else
505 res = -1; 511 res = -1;
506 errno = ENOSYS; 512 errno = ENOSYS;
507# endif
508#endif 513#endif
509 514
510 if (res < 0 515 if (res < 0
511 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK 516 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
512#if __solaris 517#if __solaris
517 { 522 {
518 /* emulate sendfile. this is a major pain in the ass */ 523 /* emulate sendfile. this is a major pain in the ass */
519 char buf[4096]; 524 char buf[4096];
520 res = 0; 525 res = 0;
521 526
522 for (;;) 527 while (count)
523 { 528 {
524 ssize_t cnt; 529 ssize_t cnt;
525 530
526 cnt = pread (ifd, buf, 4096, offset); 531 cnt = pread (ifd, buf, count > 4096 ? 4096 : count, offset);
527 532
528 if (cnt <= 0) 533 if (cnt <= 0)
529 { 534 {
530 if (cnt && !res) res = -1; 535 if (cnt && !res) res = -1;
531 break; 536 break;
539 break; 544 break;
540 } 545 }
541 546
542 offset += cnt; 547 offset += cnt;
543 res += cnt; 548 res += cnt;
549 count -= cnt;
544 } 550 }
545 } 551 }
546 552
547 return res; 553 return res;
548} 554}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines