aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2002-06-27 13:21:36 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2002-06-27 13:21:36 +0800
commitc02c6d6972779bb38953566f716e890b794edda2 (patch)
tree10884099ee5b94b5d8e907374406aac015f6f22d
parentd5898b33c70e0529370ea2cbdb8e12ee5b3ce7a5 (diff)
downloadgsoc2013-evolution-c02c6d6972779bb38953566f716e890b794edda2.tar
gsoc2013-evolution-c02c6d6972779bb38953566f716e890b794edda2.tar.gz
gsoc2013-evolution-c02c6d6972779bb38953566f716e890b794edda2.tar.bz2
gsoc2013-evolution-c02c6d6972779bb38953566f716e890b794edda2.tar.lz
gsoc2013-evolution-c02c6d6972779bb38953566f716e890b794edda2.tar.xz
gsoc2013-evolution-c02c6d6972779bb38953566f716e890b794edda2.tar.zst
gsoc2013-evolution-c02c6d6972779bb38953566f716e890b794edda2.zip
Loop on our reads while errno is EINTR or EAGAIN.
2002-06-27 Jeffrey Stedfast <fejj@ximian.com> * camel-gpg-context.c (gpg_ctx_op_step): Loop on our reads while errno is EINTR or EAGAIN. svn path=/trunk/; revision=17307
-rw-r--r--camel/ChangeLog5
-rw-r--r--camel/camel-gpg-context.c29
2 files changed, 25 insertions, 9 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 1fe9952613..183f9d8989 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,8 @@
+2002-06-27 Jeffrey Stedfast <fejj@ximian.com>
+
+ * camel-gpg-context.c (gpg_ctx_op_step): Loop on our reads while
+ errno is EINTR or EAGAIN.
+
2002-06-26 Jeffrey Stedfast <fejj@ximian.com>
* camel-pgp-context.[c,h]: Removed.
diff --git a/camel/camel-gpg-context.c b/camel/camel-gpg-context.c
index e4101071b4..6994337ecc 100644
--- a/camel/camel-gpg-context.c
+++ b/camel/camel-gpg-context.c
@@ -251,7 +251,7 @@ struct _GpgCtx {
unsigned int complete:1;
unsigned int await_read:1;
- unsigned int reading:1;
+ unsigned int reading:2;
unsigned int always_trust:1;
unsigned int armor:1;
unsigned int need_passwd:1;
@@ -262,7 +262,7 @@ struct _GpgCtx {
unsigned int validsig:1;
unsigned int trust:3;
- unsigned int padding:19;
+ unsigned int padding:18;
};
static struct _GpgCtx *
@@ -277,7 +277,7 @@ gpg_ctx_new (CamelSession *session, const char *path)
gpg->userid_hint = g_hash_table_new (g_str_hash, g_str_equal);
gpg->complete = FALSE;
gpg->await_read = FALSE;
- gpg->reading = FALSE;
+ gpg->reading = 0;
gpg->pid = (pid_t) -1;
gpg->path = g_strdup (path);
@@ -937,7 +937,9 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
d(printf ("reading from gpg's status-fd...\n"));
- nread = read (gpg->status_fd, buffer, sizeof (buffer));
+ do {
+ nread = read (gpg->status_fd, buffer, sizeof (buffer));
+ } while (nread == -1 && (errno == EINTR || errno == EAGAIN));
if (nread == -1)
goto exception;
@@ -949,14 +951,16 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
}
}
- gpg->reading = FALSE;
+ gpg->reading--;
if (FD_ISSET (gpg->stdout, &rdset) && gpg->ostream) {
char buffer[4096];
ssize_t nread;
d(printf ("reading gpg's stdout...\n"));
- nread = read (gpg->stdout, buffer, sizeof (buffer));
+ do {
+ nread = read (gpg->stdout, buffer, sizeof (buffer));
+ } while (nread == -1 && (errno == EINTR || errno == EAGAIN));
if (nread == -1)
goto exception;
@@ -967,7 +971,7 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
gpg->await_read = FALSE;
/* make sure we don't exit before reading all the data... */
- gpg->reading = TRUE;
+ gpg->reading = 3;
}
}
@@ -977,11 +981,18 @@ gpg_ctx_op_step (struct _GpgCtx *gpg, CamelException *ex)
d(printf ("reading gpg's stderr...\n"));
- nread = read (gpg->stderr, buffer, sizeof (buffer));
+ do {
+ nread = read (gpg->stderr, buffer, sizeof (buffer));
+ } while (nread == -1 && (errno == EINTR || errno == EAGAIN));
if (nread == -1)
goto exception;
- g_byte_array_append (gpg->diagnostics, buffer, nread);
+ if (nread > 0) {
+ g_byte_array_append (gpg->diagnostics, buffer, nread);
+
+ /* make sure we don't exit before reading all the data... */
+ gpg->reading = 3;
+ }
}
if (wrsetp && gpg->passwd_fd != -1 && FD_ISSET (gpg->passwd_fd, &wrset) && gpg->need_passwd && gpg->send_passwd) {