[Pkg-gnupg-commit] [gnupg2] 128/292: common, w32: Extend gnupg_create_inbound_pipe et al.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:33 UTC 2016


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

dkg pushed a commit to branch master
in repository gnupg2.

commit f2d39a6d051413289c717b9cd2dc387a270b8e7c
Author: Justus Winter <justus at g10code.com>
Date:   Tue Oct 18 13:55:12 2016 +0200

    common,w32: Extend gnupg_create_inbound_pipe et al.
    
    * common/exechelp-w32.c (do_create_pipe): Rename, add arguments, and
    create a stream if reqested.
    (gnupg_create_inbound_pipe): Use the extended function to open the
    stream if requested.
    (gnupg_create_outbound_pipe): Likewise.
    (gnupg_create_pipe): Update call site.
    
    Fixes-commit: 5d991e333a1885adc40abd9d00c01fec4bd5d9d7
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 common/exechelp-w32.c | 37 +++++++++++++++++++++++++++----------
 1 file changed, 27 insertions(+), 10 deletions(-)

diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c
index 418eb9b..c5d6b08 100644
--- a/common/exechelp-w32.c
+++ b/common/exechelp-w32.c
@@ -301,7 +301,8 @@ w32_open_null (int for_write)
 
 
 static gpg_error_t
-do_create_pipe (int filedes[2], int flags)
+create_pipe_and_estream (int filedes[2], int flags,
+                         estream_t *r_fp, int outbound, int nonblock)
 {
   gpg_error_t err = 0;
   HANDLE fds[2];
@@ -330,6 +331,25 @@ do_create_pipe (int filedes[2], int flags)
             err = 0;
         }
     }
+
+  if (! err && r_fp)
+    {
+      if (!outbound)
+        *r_fp = es_fdopen (filedes[0], nonblock? "r,nonblock" : "r");
+      else
+        *r_fp = es_fdopen (filedes[1], nonblock? "w,nonblock" : "w");
+      if (!*r_fp)
+        {
+          err = my_error_from_syserror ();
+          log_error (_("error creating a stream for a pipe: %s\n"),
+                     gpg_strerror (err));
+          close (filedes[0]);
+          close (filedes[1]);
+          filedes[0] = filedes[1] = -1;
+          return err;
+        }
+    }
+
   return err;
 }
 
@@ -339,10 +359,8 @@ do_create_pipe (int filedes[2], int flags)
 gpg_error_t
 gnupg_create_inbound_pipe (int filedes[2], estream_t *r_fp, int nonblock)
 {
-  if (r_fp)
-    return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
-  else
-    return do_create_pipe (filedes, INHERIT_WRITE);
+  return create_pipe_and_estream (filedes, INHERIT_WRITE,
+                                  r_fp, 0, nonblock);
 }
 
 
@@ -352,10 +370,8 @@ gnupg_create_inbound_pipe (int filedes[2], estream_t *r_fp, int nonblock)
 gpg_error_t
 gnupg_create_outbound_pipe (int filedes[2], estream_t *r_fp, int nonblock)
 {
-  if (r_fp)
-    return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
-  else
-    return do_create_pipe (filedes, INHERIT_READ);
+  return create_pipe_and_estream (filedes, INHERIT_READ,
+                                  r_fp, 1, nonblock);
 }
 
 
@@ -364,7 +380,8 @@ gnupg_create_outbound_pipe (int filedes[2], estream_t *r_fp, int nonblock)
 gpg_error_t
 gnupg_create_pipe (int filedes[2])
 {
-  return do_create_pipe (filedes, INHERIT_BOTH);
+  return create_pipe_and_estream (filedes, INHERIT_BOTH,
+                                  NULL, 0, 0);
 }
 
 

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



More information about the Pkg-gnupg-commit mailing list