[Pkg-gnupg-commit] [libassuan] 220/437: 2007-10-05 Marcus Brinkmann <marcus at g10code.de>

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:33:45 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 d0395d1de508b960fa8d7c83e404d7aacb617c9c
Author: Marcus Brinkmann <mb at g10code.com>
Date:   Fri Oct 5 16:44:08 2007 +0000

    2007-10-05  Marcus Brinkmann  <marcus at g10code.de>
    
    	* assuan-defs.h (_assuan_error_is_eagain): New prototype.
    	* mkerrors (_assuan_error_is_eagain): New function.
    	* assuan-handler.c (process_next): Leave on EAGAIN.
    	* assuan-handler.c (process_request),
    	assuan-client.c (_assuan_read_from_server),
    	assuan-buffer.c (assuan_read_line): Busy loop over EAGAIN.
---
 src/ChangeLog        |  9 +++++++++
 src/assuan-buffer.c  |  9 +++++++--
 src/assuan-client.c  |  6 +++++-
 src/assuan-defs.h    |  2 ++
 src/assuan-handler.c |  8 +++++++-
 src/mkerrors         | 13 +++++++++++++
 6 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 53fd37a..ea2a89d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,12 @@
+2007-10-05  Marcus Brinkmann  <marcus at g10code.de>
+
+	* assuan-defs.h (_assuan_error_is_eagain): New prototype.
+	* mkerrors (_assuan_error_is_eagain): New function.
+	* assuan-handler.c (process_next): Leave on EAGAIN.
+	* assuan-handler.c (process_request),
+	assuan-client.c (_assuan_read_from_server),
+	assuan-buffer.c (assuan_read_line): Busy loop over EAGAIN.
+
 2007-10-05  Werner Koch  <wk at g10code.com>
 
 	* assuan-socket.c (_assuan_sock_wsa2errno): Map WSANOTINITIALISED.
diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c
index 2016864..3968584 100644
--- a/src/assuan-buffer.c
+++ b/src/assuan-buffer.c
@@ -93,7 +93,7 @@ readline (assuan_context_t ctx, char *buf, size_t buflen,
 }
 
 
-/* Function returns an Assuan error. */
+/* Function returns an Assuan error.  */
 assuan_error_t
 _assuan_read_line (assuan_context_t ctx)
 {
@@ -245,7 +245,12 @@ assuan_read_line (assuan_context_t ctx, char **line, size_t *linelen)
   if (!ctx)
     return _assuan_error (ASSUAN_Invalid_Value);
 
-  err = _assuan_read_line (ctx);
+  do
+    {
+      err = _assuan_read_line (ctx);
+    }
+  while (_assuan_error_is_eagain (err));
+
   *line = ctx->inbound.line;
   *linelen = ctx->inbound.linelen;
   return err;
diff --git a/src/assuan-client.c b/src/assuan-client.c
index 090e7fc..15f4f1c 100644
--- a/src/assuan-client.c
+++ b/src/assuan-client.c
@@ -42,7 +42,11 @@ _assuan_read_from_server (assuan_context_t ctx, int *okay, int *off)
   *off = 0;
   do 
     {
-      rc = _assuan_read_line (ctx);
+      do
+	{
+	  rc = _assuan_read_line (ctx);
+	}
+      while (_assuan_error_is_eagain (rc));
       if (rc)
         return rc;
       line = ctx->inbound.line;
diff --git a/src/assuan-defs.h b/src/assuan-defs.h
index 1e31c43..f17e906 100644
--- a/src/assuan-defs.h
+++ b/src/assuan-defs.h
@@ -234,6 +234,8 @@ void _assuan_inquire_release (assuan_context_t ctx);
 /* Map error codes as used in this implementation to the libgpg-error
    codes. */
 assuan_error_t _assuan_error (int oldcode);
+/* Check if ERR means EAGAIN.  */
+int _assuan_error_is_eagain (assuan_error_t err);
 
 /* Extract the error code from A.  This works for both the old and the
    new style error codes.  This needs to be used whenever an error
diff --git a/src/assuan-handler.c b/src/assuan-handler.c
index 4c02608..0b9700e 100644
--- a/src/assuan-handler.c
+++ b/src/assuan-handler.c
@@ -612,6 +612,8 @@ process_next (assuan_context_t ctx)
      required to write full lines without blocking long after starting
      a partial line.  */
   rc = _assuan_read_line (ctx);
+  if (_assuan_error_is_eagain (rc))
+    return 0;
   if (rc)
     return rc;
   if (*ctx->inbound.line == '#' || !ctx->inbound.linelen)
@@ -683,7 +685,11 @@ process_request (assuan_context_t ctx)
   if (ctx->in_inquire)
     return _assuan_error (ASSUAN_Nested_Commands);
 
-  rc = _assuan_read_line (ctx);
+  do
+    {
+      rc = _assuan_read_line (ctx);
+    }
+  while (_assuan_error_is_eagain (rc));
   if (rc)
     return rc;
   if (*ctx->inbound.line == '#' || !ctx->inbound.linelen)
diff --git a/src/mkerrors b/src/mkerrors
index feded4f..33a9284 100755
--- a/src/mkerrors
+++ b/src/mkerrors
@@ -141,6 +141,19 @@ _assuan_error (int oldcode)
 }
 
 
+/* A small helper function to treat EAGAIN transparently to the
+   caller.  */
+int
+_assuan_error_is_eagain (assuan_error_t err)
+{
+  if ((!err_source && err == ASSUAN_Read_Error && errno == EAGAIN)
+      || (err_source && (err & ((1 << 24) - 1)) == (6 | (1 << 15))))
+    return 1;
+  else
+    return 0;
+}
+   
+
 /**
  * assuan_strerror:
  * @err:  Error code 

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