[Pkg-gnupg-commit] [libassuan] 194/437: Better error code mapping.

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:33:42 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libassuan.

commit 343ee20b72084f7fe4a9deea05dd511f68d768a1
Author: Werner Koch <wk at gnupg.org>
Date:   Thu Jul 12 15:26:33 2007 +0000

    Better error code mapping.
---
 src/ChangeLog       |  3 +++
 src/assuan-io-pth.c |  2 +-
 src/assuan-io.c     | 13 +++++++++++--
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index a9616e6..ad04bb9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -14,6 +14,9 @@
 	* assuan-handler.c (assuan_get_active_fds) [W32]: Use
 	_get_osfhandle for the data fp.
 
+	* assuan-io.c (_assuan_simple_write): Return EPIPE on a closed pipe.
+	(_assuan_simple_read): Likewise
+	
 2007-07-08  Marcus Brinkmann  <marcus at g10code.de>
 
 	* assuan-defs.h (struct assuan_context_s): Have full peercred
diff --git a/src/assuan-io-pth.c b/src/assuan-io-pth.c
index ff6f10d..69774ff 100644
--- a/src/assuan-io-pth.c
+++ b/src/assuan-io-pth.c
@@ -54,7 +54,7 @@ _assuan_waitpid (pid_t pid, int *status, int options)
 ssize_t
 _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
 {
-  /* Fixme: For W32 we ehsould better not cast the HANDLE type to int.
+  /* Fixme: For W32 we should better not cast the HANDLE type to int.
      However, this requires changes in w32pth too.  */
   return pth_read ((int)ctx->inbound.fd, buffer, size);
 }
diff --git a/src/assuan-io.c b/src/assuan-io.c
index 7ce43cb..a5e3816 100644
--- a/src/assuan-io.c
+++ b/src/assuan-io.c
@@ -63,7 +63,11 @@ _assuan_simple_read (assuan_context_t ctx, void *buffer, size_t size)
       n = ReadFile (ctx->inbound.fd, buffer, size, &nread, NULL);
       if (!n)
         {
-          errno = EIO; /* FIXME:  We should have a proper mapping.  */
+          switch (GetLastError())
+            {
+            case ERROR_BROKEN_PIPE: errno = EPIPE; break;
+            default: errno = EIO; 
+            }
           n = -1;
         }
       else
@@ -92,7 +96,12 @@ _assuan_simple_write (assuan_context_t ctx, const void *buffer, size_t size)
       n = WriteFile (ctx->outbound.fd, buffer, size, &nwrite, NULL);
       if (!n)
         {
-          errno = EIO; /* FIXME:  We should have a proper mapping.  */
+          switch (GetLastError ())
+            {
+            case ERROR_BROKEN_PIPE: 
+            case ERROR_NO_DATA: errno = EPIPE; break;
+            default:            errno = EIO;   break;
+            }
           n = -1;
         }
       else

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git



More information about the Pkg-gnupg-commit mailing list