[Pkg-gnupg-commit] [libassuan] 139/437: * assuan-util.c (assuan_set_flag, assuan_get_flag): New. * assuan-defs.h (struct assuan_context_s): New field flags. * assuan.h (assuan_flag_t): New with one flag value ASSUAN_NO_WAITPID for now. * assuan-pipe-connect.c (do_finish): Take care of the no_waitpid flag.

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:33:34 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 4f91409361e295735adacc08329ed43f3d95b813
Author: Werner Koch <wk at gnupg.org>
Date:   Sun May 22 07:33:51 2005 +0000

    * assuan-util.c (assuan_set_flag, assuan_get_flag): New.
    * assuan-defs.h (struct assuan_context_s): New field flags.
    * assuan.h (assuan_flag_t): New with one flag value
    ASSUAN_NO_WAITPID for now.
    * assuan-pipe-connect.c (do_finish): Take care of the no_waitpid
    flag.
---
 NEWS                      |  4 ++++
 THANKS                    |  2 ++
 src/ChangeLog             |  9 +++++++++
 src/assuan-defs.h         | 16 ++++++++++++----
 src/assuan-pipe-connect.c |  5 ++---
 src/assuan-util.c         | 30 ++++++++++++++++++++++++++++++
 src/assuan.h              | 21 +++++++++++++++++++++
 7 files changed, 80 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index 9b640aa..8427983 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,10 @@
 Noteworthy changes in version 0.6.10
 ------------------------------------------------
 
+ * New functions assuan_get_flag and assuan_set_flag.
+
+ * Add flag ASSUAN_NO_WAITPID.
+
 
 Noteworthy changes in version 0.6.9 (2004-12-22)
 ------------------------------------------------
diff --git a/THANKS b/THANKS
index 8bdbc1c..58daa20 100644
--- a/THANKS
+++ b/THANKS
@@ -1,5 +1,7 @@
 
 Marc Mutz                 mutz at kde.org
 Michael Nottebrock        michaelnottebrock at gmx.net
+Ville Skyttä              ville.skytta at iki.fi
+
 
 
diff --git a/src/ChangeLog b/src/ChangeLog
index b74f0a1..544184f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2005-05-21  Werner Koch  <wk at g10code.com>
+
+	* assuan-util.c (assuan_set_flag, assuan_get_flag): New.
+	* assuan-defs.h (struct assuan_context_s): New field flags.
+	* assuan.h (assuan_flag_t): New with one flag value
+	ASSUAN_NO_WAITPID for now.
+	* assuan-pipe-connect.c (do_finish): Take care of the no_waitpid
+	flag.
+
 2005-04-04  Werner Koch  <wk at g10code.com>
 
 	* assuan-util.c (_assuan_calloc): Avoid integer overflow.
diff --git a/src/assuan-defs.h b/src/assuan-defs.h
index a5b45ee..2917fe8 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -84,15 +84,22 @@ struct assuan_context_s
 {
   assuan_error_t err_no;
   const char *err_str;
-  int os_errno;  /* last system error number used with certain error codes*/
+  int os_errno;       /* Last system error number used with certain
+                         error codes. */
+
+  /* Context specific flags (cf. assuan_flag_t). */
+  struct 
+  {
+    unsigned int no_waitpid:1; /* See ASSUAN_NO_WAITPID. */
+  } flags; 
 
   int confidential;
-  int is_server;  /* set if this is context belongs to a server */
+  int is_server;      /* Set if this is context belongs to a server */
   int in_inquire;
   char *hello_line;
-  char *okay_line; /* see assan_set_okay_line() */
+  char *okay_line;    /* See assuan_set_okay_line() */
   
-  void *user_pointer;  /* for assuan_[gs]et_pointer () */
+  void *user_pointer;  /* For assuan_get_pointer and assuan-set_pointer (). */
 
   FILE *log_fp;
 
@@ -126,6 +133,7 @@ struct assuan_context_s
   int listen_fd;  /* The fd we are listening on (used by socket servers) */
   int connected_fd; /* helper */
 
+
   /* Used for Unix domain sockets.  */
   struct sockaddr_un myaddr;
   struct sockaddr_un serveraddr;
diff --git a/src/assuan-pipe-connect.c b/src/assuan-pipe-connect.c
index 1ca6948..5b952b2 100644
--- a/src/assuan-pipe-connect.c
+++ b/src/assuan-pipe-connect.c
@@ -119,9 +119,8 @@ do_finish (assuan_context_t ctx)
   if (ctx->pid != -1 && ctx->pid)
     {
 #ifndef HAVE_W32_SYSTEM
-      /* FIXME: Does it really make sense to use the waitpid?  What
-         about using a double fork and forget abnout it. */
-      waitpid (ctx->pid, NULL, 0);  /* FIXME Check return value.  */
+      if (!ctx->flags.no_waitpid)
+        waitpid (ctx->pid, NULL, 0); 
       ctx->pid = -1;
 #endif /*!HAVE_W32_SYSTEM*/
     }
diff --git a/src/assuan-util.c b/src/assuan-util.c
index 2c9299a..7f442e9 100644
--- a/src/assuan-util.c
+++ b/src/assuan-util.c
@@ -136,6 +136,36 @@ assuan_end_confidential (assuan_context_t ctx)
     }
 }
 
+
+
+/* For context CTX, set the flag FLAG to VALUE.  Values for flags
+   are usually 1 or 0 but certain flags might allow for other values;
+   see the description of the type assuan_flag_t for details. */
+void
+assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value)
+{
+  if (!ctx)
+    return;
+  switch (flag)
+    {
+    case ASSUAN_NO_WAITPID: ctx->flags.no_waitpid = value; break;
+    }
+}
+
+/* Return the VALUE of FLAG in context CTX. */ 
+int
+assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag)
+{
+  if (!ctx)
+    return 0;
+  switch (flag)
+    {
+    case ASSUAN_NO_WAITPID: return ctx->flags.no_waitpid;
+    }
+  return 0;
+}
+
+
 /* Dump a possibly binary string (used for debugging).  Distinguish
    ascii text from binary and print it accordingly.  */
 void
diff --git a/src/assuan.h b/src/assuan.h
index 890f3b0..e8076a8 100644
--- a/src/assuan.h
+++ b/src/assuan.h
@@ -134,6 +134,18 @@ typedef enum
 } AssuanCommand;
 
 
+/* Definitions of flags for assuan_set_flag(). */
+typedef enum
+  {
+    /* When using a pipe server, by default Assuan will wait for the
+       forked process to die in assuan_disconnect.  In certain cases
+       this is not desirable.  By setting this flag, the waitpid will
+       be skipped and the caller is responsible to cleanup a forked
+       process. */
+    ASSUAN_NO_WAITPID = 1
+  } 
+assuan_flag_t;
+
 #define ASSUAN_LINELENGTH 1002 /* 1000 + [CR,]LF */
 
 struct assuan_context_s;
@@ -274,6 +286,15 @@ void *assuan_get_pointer (assuan_context_t ctx);
 void assuan_begin_confidential (assuan_context_t ctx);
 void assuan_end_confidential (assuan_context_t ctx);
 
+/* For context CTX, set the flag FLAG to VALUE.  Values for flags
+   are usually 1 or 0 but certain flags might allow for other values;
+   see the description of the type assuan_flag_t for details. */
+void assuan_set_flag (assuan_context_t ctx, assuan_flag_t flag, int value);
+
+/* Return the VALUE of FLAG in context CTX. */ 
+int  assuan_get_flag (assuan_context_t ctx, assuan_flag_t flag);
+
+
 /*-- assuan-errors.c (built) --*/
 const char *assuan_strerror (assuan_error_t err);
 

-- 
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