The current callers for the compression code do not install signal
handlers, so there is no occasion to test the EINTR handling.
Perhaps for this reason, since commit 7bf6e0 (add support for using
libz, 2000-12-09) when the current compression/decompression code
was introduced, the EINTR handling has been broken in a number of
ways:

 * interrupted reads were treated as end of file until very
   recently
 * interrupted writes during decompression cause portions of the
   output to be discarded
 * interrupted writes during compression are treated as errors,
   unless the interruption happens before any data from the
   output buffer can be consumed

Since zlib at least cannot recover from an interrupted write
anyway, it seems better to always treat EINTR like any other error.
Callers should specify the SA_RESTART flag when installing signal
handlers for correct behavior on System V style operating systems
(such as Solaris).

Signed-off-by: Jonathan Nieder <jrnie...@gmail.com>
---
 lib/dpkg/compression.c |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/dpkg/compression.c b/lib/dpkg/compression.c
index 31da38d..821c0a4 100644
--- a/lib/dpkg/compression.c
+++ b/lib/dpkg/compression.c
@@ -47,11 +47,9 @@ fd_fd_filter(int fd_in, int fd_out,
     if (actualread < 0) { \
       int err = 0; \
       const char *errmsg = zerror(zfile, &err); \
-      if (err == ERR_ERRNO) { \
-        if (errno == EINTR) \
-          continue; \
+      \
+      if (err == ERR_ERRNO) \
         errmsg = strerror(errno); \
-      } \
       ohshit(_("%s: internal " format " error: %s: %s"), \
              desc, "read", errmsg); \
     } \
@@ -72,21 +70,17 @@ fd_fd_filter(int fd_in, int fd_out,
   combuf[1] = compression; \
   zfile = zdopen(fd_out, combuf); \
   while ((actualread = read(fd_in, buffer, sizeof(buffer)))) { \
-    if (actualread < 0) { \
-      if (errno == EINTR) \
-        continue; \
+    if (actualread < 0) \
       ohshite(_("%s: internal " format " error: %s"), \
               desc, "read"); \
-    } \
+    \
     actualwrite = zwrite(zfile, buffer, actualread); \
     if (actualwrite != actualread) { \
       int err = 0; \
       const char *errmsg = zerror(zfile, &err); \
-      if (err == ERR_ERRNO) { \
-        if (errno == EINTR) \
-          continue; \
+      \
+      if (err == ERR_ERRNO) \
         errmsg = strerror(errno); \
-      } \
       ohshit(_("%s: internal " format " error: %s: %s"), \
               desc, "write", errmsg); \
     } \
-- 
1.6.5.rc1.199.g596ec


-- 
To UNSUBSCRIBE, email to debian-dpkg-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to