From ed49b72c0a31b6034026948851edf11cfa990fa0 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 1 Feb 2015 12:06:52 +0000 Subject: Add allreadwritev and friends --- src/include/skalibs/allreadwrite.h | 6 ++++++ src/include/skalibs/functypes.h | 8 ++++++++ src/libstddjb/allreadwrite.c | 1 - src/libstddjb/buffer_write.c | 7 ++----- 4 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/include/skalibs/allreadwrite.h b/src/include/skalibs/allreadwrite.h index 6b2a0cf..d2e6bf7 100644 --- a/src/include/skalibs/allreadwrite.h +++ b/src/include/skalibs/allreadwrite.h @@ -6,11 +6,13 @@ #include #include #include +#include extern int sanitize_read (int) ; extern int unsanitize_read (int) ; extern unsigned int allreadwrite (iofunc_t_ref, int, char *, unsigned int) ; +extern unsigned int allreadwritev (iovfunc_t_ref, int, siovec_t const *, unsigned int) ; extern int fd_read (int, char *, unsigned int) ; extern int fd_write (int, char const *, unsigned int) ; @@ -20,8 +22,12 @@ extern int fd_send (int, char const *, unsigned int, unsigned int) ; extern unsigned int allread (int, char *, unsigned int) ; extern unsigned int allwrite (int, char const *, unsigned int) ; +extern unsigned int allreadv (int, siovec_t const *, unsigned int) ; +extern unsigned int allwritev (int, siovec_t const *, unsigned int) ; extern int fd_readv (int, struct iovec const *, unsigned int) ; +extern int fd_readsv (int, siovec_t const *, unsigned int) ; extern int fd_writev (int, struct iovec const *, unsigned int) ; +extern int fd_writesv (int, siovec_t const *, unsigned int) ; #endif diff --git a/src/include/skalibs/functypes.h b/src/include/skalibs/functypes.h index 15cdbcc..d7094fc 100644 --- a/src/include/skalibs/functypes.h +++ b/src/include/skalibs/functypes.h @@ -3,6 +3,8 @@ #ifndef FUNCTYPES_H #define FUNCTYPES_H +#include + typedef int uintcmpfunc_t (unsigned int, unsigned int, void *) ; typedef uintcmpfunc_t *uintcmpfunc_t_ref ; @@ -27,7 +29,13 @@ typedef uinitfunc_t *uinitfunc_t_ref ; typedef int iofunc_t (int, char *, unsigned int) ; typedef iofunc_t *iofunc_t_ref ; +typedef int iovfunc_t (int, siovec_t const *, unsigned int) ; +typedef iovfunc_t *iovfunc_t_ref ; + typedef unsigned int alliofunc_t (int, char *, unsigned int) ; typedef alliofunc_t *alliofunc_t_ref ; +typedef unsigned int alliovfunc_t (int, siovec_t const *, unsigned int) ; +typedef alliovfunc_t *alliovfunc_t_ref ; + #endif diff --git a/src/libstddjb/allreadwrite.c b/src/libstddjb/allreadwrite.c index 7e7867b..c15f6de 100644 --- a/src/libstddjb/allreadwrite.c +++ b/src/libstddjb/allreadwrite.c @@ -9,7 +9,6 @@ unsigned int allreadwrite (iofunc_t_ref op, int fd, register char *buf, register while (len) { register int w = (*op)(fd, buf, len) ; - if (!w) errno = EPIPE ; if (w <= 0) break ; written += w ; buf += w ; diff --git a/src/libstddjb/buffer_write.c b/src/libstddjb/buffer_write.c index e669f60..b924cbb 100644 --- a/src/libstddjb/buffer_write.c +++ b/src/libstddjb/buffer_write.c @@ -1,14 +1,11 @@ /* ISC license. */ -#include -#include #include #include #include int buffer_write (int fd, siovec_t const *v, unsigned int n) { - struct iovec iov[n] ; - iovec_from_siovec(iov, v, n) ; - return fd_writev(fd, iov, n) ; + unsigned int w = allreadwritev(&fd_writesv, fd, v, n) ; + return w ? (int)w : -1 ; } -- cgit v1.2.3