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.32 by root, Mon Aug 22 23:20:37 2005 UTC vs.
Revision 1.36 by root, Tue Aug 23 01:18:04 2005 UTC

23# elif __freebsd 23# elif __freebsd
24# include <sys/socket.h> 24# include <sys/socket.h>
25# include <sys/uio.h> 25# include <sys/uio.h>
26# elif __hpux 26# elif __hpux
27# include <sys/socket.h> 27# include <sys/socket.h>
28# elif __solaris /* not yet */
29# include <sys/sendfile.h>
30# else
31# error sendfile support requested but not available
28# endif 32# endif
29#endif 33#endif
30 34
31#if __ia64 35#if __ia64
32# define STACKSIZE 65536 36# define STACKSIZE 65536
437 ssize_t res; 441 ssize_t res;
438 442
439 if (!count) 443 if (!count)
440 return 0; 444 return 0;
441 445
446#if HAVE_SENDFILE
442#if __linux 447# if __linux
443 res = sendfile (ofd, ifd, &offset, count); 448 res = sendfile (ofd, ifd, &offset, count);
444 449
445#elif __freebsd 450# elif __freebsd
446 /* 451 /*
447 * Of course, the freebsd sendfile is a dire hack with no thoughts 452 * Of course, the freebsd sendfile is a dire hack with no thoughts
448 * wasted on making it similar to other i/o functions. 453 * wasted on making it similar to other I/O functions.
449 */ 454 */
450 { 455 {
451 off_t sbytes; 456 off_t sbytes;
452 res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); 457 res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0);
453 458
454 if (!res && errno == EAGAIN) 459 if (res < 0 && sbytes)
460 /* maybe only on EAGAIN only: as usual, the manpage leaves you guessing */
455 res = sbytes; 461 res = sbytes;
456 } 462 }
457 463
458#elif __hpux 464# elif __hpux
459 res = sendfile (ofd, ifd, offset, count, 0, 0); 465 res = sendfile (ofd, ifd, offset, count, 0, 0);
460 466
467# elif __solaris
468 {
469 struct sendfilevec vec;
470 size_t sbytes;
471
472 vec.sfv_fd = ifd;
473 vec.sfv_flag = 0;
474 vec.sfv_off = offset;
475 vec.sfv_len = count;
476
477 res = sendfilev (ofd, &vec, 1, &sbytes);
478
479 if (res < 0 && sbytes)
480 res = sbytes;
481 }
482
461#else 483# else
462 res = -1; 484 res = -1;
463 errno = ENOSYS; 485 errno = ENOSYS;
486# endif
464#endif 487#endif
465 488
489 if (res < 0
466 if (res < 0 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK)) 490 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
491#if __solaris
492 || errno == EAFNOSUPPORT || errno == EPROTOTYPE
493#endif
494 )
495 )
467 { 496 {
468 /* emulate sendfile. this is a major pain in the ass */ 497 /* emulate sendfile. this is a major pain in the ass */
469 char *buf = malloc (4096); 498 char *buf = malloc (4096);
470 res = 0; 499 res = 0;
471 500

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines