From 46bba132c7e353a3bba252ddf4f484b0c237ac46 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Thu, 27 Jun 2002 23:16:37 +0000 Subject: Loop on our reads while errno is EINTR or EAGAIN. Also make sure to 2002-06-27 Jeffrey Stedfast * camel-gpg-context.c (gpg_ctx_op_step): Loop on our reads while errno is EINTR or EAGAIN. Also make sure to completely read stdout and stderr by keeping better state. (gpg_ctx_parse_status): In the case of a NODATA response from gpg, try to use the diagnostics that gpg may have written to its stderr. svn path=/trunk/; revision=17319 --- camel/camel-gpg-context.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'camel/camel-gpg-context.c') diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c index 2483a10c59..7d5f167d64 100644 --- a/camel/camel-gpg-context.c +++ b/camel/camel-gpg-context.c @@ -778,8 +778,12 @@ gpg_ctx_parse_status (struct _GpgCtx *gpg, CamelException *ex) return -1; } else if (!strncmp (status, "NODATA", 6)) { /* this is an error */ - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, - _("No data provided")); + if (gpg->diagnostics->len) + camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, "%.*s", + gpg->diagnostics->len, gpg->diagnostics->data); + else + camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + _("No data provided")); return -1; } else { /* check to see if we are complete */ @@ -1023,7 +1027,7 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex) char buffer[4096]; ssize_t nread; - d(printf ("writing to gpg's stdin...")); + d(printf ("writing to gpg's stdin...\n")); /* write our stream to gpg's stdin */ nread = camel_stream_read (gpg->istream, buffer, sizeof (buffer)); @@ -1039,11 +1043,14 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex) nwritten += w; } while (nwritten < nread && w != -1); + d(printf ("wrote %d (out of %d) bytes to gpg's stdin\n", nwritten, nread)); + if (w == -1) goto exception; } if (camel_stream_eos (gpg->istream)) { + d(printf ("closing gpg's stdin\n")); close (gpg->stdin); gpg->stdin = -1; } -- cgit