From eb23d21b3da0789c19a2e97306745be443567d41 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 30 Oct 2012 12:38:20 +0200 Subject: Handle EINTR in Fread() and Fwrite() - Not all systems automatically restart signal-interrupted operations, handle this centrally since its so easy to do. Also related to RhBug:580974. --- rpmio/rpmio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'rpmio/rpmio.c') diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index 6feae8633..725cc7478 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -1216,7 +1216,9 @@ ssize_t Fread(void *buf, size_t size, size_t nmemb, FD_t fd) fdio_read_function_t _read = FDIOVEC(fd, read); fdstat_enter(fd, FDSTAT_READ); - rc = (_read ? (*_read) (fd, buf, size * nmemb) : -2); + do { + rc = (_read ? (*_read) (fd, buf, size * nmemb) : -2); + } while (rc == -1 && errno == EINTR); fdstat_exit(fd, FDSTAT_READ, rc); if (fd->digests && rc > 0) @@ -1237,7 +1239,9 @@ ssize_t Fwrite(const void *buf, size_t size, size_t nmemb, FD_t fd) fdio_write_function_t _write = FDIOVEC(fd, write); fdstat_enter(fd, FDSTAT_WRITE); - rc = (_write ? _write(fd, buf, size * nmemb) : -2); + do { + rc = (_write ? _write(fd, buf, size * nmemb) : -2); + } while (rc == -1 && errno == EINTR); fdstat_exit(fd, FDSTAT_WRITE, rc); if (fd->digests && rc > 0) -- cgit v1.2.3