[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH 17/15] libdpkg: compression: do not handle EINTR



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 <jrnieder@gmail.com>
---
 lib/dpkg/compression-backend.c |   18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/lib/dpkg/compression-backend.c b/lib/dpkg/compression-backend.c
index 551a54a..edd28b5 100644
--- a/lib/dpkg/compression-backend.c
+++ b/lib/dpkg/compression-backend.c
@@ -105,11 +105,9 @@ default_memlimit()
 		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); \
 		} \
@@ -129,21 +127,17 @@ default_memlimit()
 	\
 	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


Reply to: