From 2791749f220602482c2cce772e6520c54218c0dd Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Tue, 17 Dec 2019 20:35:28 +0000 Subject: GNU/Hurd: retry EINTR returns from pipe I/O Replaces: a76f64c3d4 --- src/OS/Makefile-Base | 6 ++++-- src/OS/os.c-GNU | 35 +++++++++++++++++++++++++++++++++++ src/OS/os.h-GNU | 6 +++++- 3 files changed, 44 insertions(+), 3 deletions(-) (limited to 'src/OS') diff --git a/src/OS/Makefile-Base b/src/OS/Makefile-Base index 36af8308d..1ab3ac35f 100644 --- a/src/OS/Makefile-Base +++ b/src/OS/Makefile-Base @@ -644,7 +644,8 @@ HDRS = blob.h \ mytypes.h \ sha_ver.h \ structs.h \ - os.h + os.h \ + osfunctions.h PHDRS = ../config.h \ ../dbfunctions.h \ ../dbstuff.h \ @@ -655,7 +656,8 @@ PHDRS = ../config.h \ ../macros.h \ ../mytypes.h \ ../structs.h \ - ../os.h + ../os.h \ + ../osfunctions.h .SUFFIXES: .o .c .c.o:; @echo "$(CC) $*.c" diff --git a/src/OS/os.c-GNU b/src/OS/os.c-GNU index e5d6ff66c..06226839b 100644 --- a/src/OS/os.c-GNU +++ b/src/OS/os.c-GNU @@ -52,4 +52,39 @@ return -1; } #endif /* OS_LOAD_AVERAGE */ + +ssize_t +os_pipe_read(int fd, void * buf, size_t count) +{ +for (int rc, retries = 10; retries > 0; retries--) + { + if ((rc = read(fd, buf, count) >= 0) break; + if (rc != -1 || errno != EINTR) break; + } +return rc; +} + + +ssize_t +os_pipe_write(int fd, void * buf, size_t count) +{ +for (int rc, retries = 10; retries > 0; retries--) + { + if ((rc = write(fd, buf, count) >= 0) break; + if (rc != -1 || errno != EINTR) break; + } +return rc; +} + +ssize_t +os_pipe_writev(int fd, const struct iovec * iov, int iovcnt +{ +for (int rc, retries = 10; retries > 0; retries--) + { + if ((rc = writev(fd, iov, iovcnt) >= 0) break; + if (rc != -1 || errno != EINTR) break; + } +return rc; +} + /* End of os.c-GNU */ diff --git a/src/OS/os.h-GNU b/src/OS/os.h-GNU index 1de2e3e84..772d278ad 100644 --- a/src/OS/os.h-GNU +++ b/src/OS/os.h-GNU @@ -21,7 +21,11 @@ typedef struct flock flock_t; #define ICONV_ARG2_TYPE const char ** /* setgroups(0, NULL) succeeds, and drops the gid group -as well as any supplementary groups*/ +as well as any supplementary groups */ #define OS_SETGROUPS_ZERO_DROPS_ALL +/* reads and writes on pipes frequently return EINTR. We provide +a routine to retry that */ +#define OS_PIPE_RW_EINTR + /* End */ -- cgit v1.2.3