From 06247775aa9c49ffce72827921eb45e2d04c6aa1 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 8 Jun 2010 15:47:34 -0400 Subject: Properly handle read() and write() throughout the SSSD We need to guarantee at all times that reads and writes complete successfully. This means that they must be checked for returning EINTR and EAGAIN, and all writes must be wrapped in a loop to ensure that they do not truncate their output. --- src/util/backup_file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/util/backup_file.c') diff --git a/src/util/backup_file.c b/src/util/backup_file.c index cf9ddf303..990793278 100644 --- a/src/util/backup_file.c +++ b/src/util/backup_file.c @@ -86,7 +86,7 @@ int backup_file(const char *src_file, int dbglvl) while (1) { num = read(src_fd, buf, BUFFER_SIZE); if (num < 0) { - if (errno == EINTR) continue; + if (errno == EINTR || errno == EAGAIN) continue; ret = errno; DEBUG(dbglvl, ("Error (%d [%s]) reading from source %s\n", ret, strerror(ret), src_file)); @@ -101,7 +101,7 @@ int backup_file(const char *src_file, int dbglvl) errno = 0; num = write(dst_fd, &buf[pos], count); if (num < 0) { - if (errno == EINTR) continue; + if (errno == EINTR || errno == EAGAIN) continue; ret = errno; DEBUG(dbglvl, ("Error (%d [%s]) writing to destination %s\n", ret, strerror(ret), dst_file)); -- cgit