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.34 by root, Tue Aug 23 00:03:14 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>
28# else 30# else
29# error sendfile support requested but not available 31# error sendfile support requested but not available
30# endif 32# endif
31#endif 33#endif
32 34
439 ssize_t res; 441 ssize_t res;
440 442
441 if (!count) 443 if (!count)
442 return 0; 444 return 0;
443 445
446#if HAVE_SENDFILE
444#if __linux 447# if __linux
445 res = sendfile (ofd, ifd, &offset, count); 448 res = sendfile (ofd, ifd, &offset, count);
446 449
447#elif __freebsd 450# elif __freebsd
448 /* 451 /*
449 * 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
450 * wasted on making it similar to other i/o functions. 453 * wasted on making it similar to other I/O functions.
451 */ 454 */
452 { 455 {
453 off_t sbytes; 456 off_t sbytes;
454 res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0); 457 res = sendfile (ifd, ofd, offset, count, 0, &sbytes, 0);
455 458
456 if (!res && errno == EAGAIN) 459 if (res < 0 && sbytes)
457 /* maybe on others, too, as usual, the manpage leaves you guessing */ 460 /* maybe only on EAGAIN only: as usual, the manpage leaves you guessing */
458 res = sbytes; 461 res = sbytes;
459 } 462 }
460 463
461#elif __hpux 464# elif __hpux
462 res = sendfile (ofd, ifd, offset, count, 0, 0); 465 res = sendfile (ofd, ifd, offset, count, 0, 0);
463 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
464#else 483# else
465 res = -1; 484 res = -1;
466 errno = ENOSYS; 485 errno = ENOSYS;
486# endif
467#endif 487#endif
468 488
489 if (res < 0
469 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 )
470 { 496 {
471 /* emulate sendfile. this is a major pain in the ass */ 497 /* emulate sendfile. this is a major pain in the ass */
472 char *buf = malloc (4096); 498 char *buf = malloc (4096);
473 res = 0; 499 res = 0;
474 500

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines