Re: [Evolution-hackers] Deadlock in camel-gpg-context.c
- From: Jeffrey Stedfast <fejj ximian com>
- To: Christophe Saout <christophe saout de>
- Cc: evolution-hackers ximian com
- Subject: Re: [Evolution-hackers] Deadlock in camel-gpg-context.c
- Date: 21 Apr 2003 13:41:05 -0400
When can this condition ever happen?
Jeff
On Mon, 2003-04-21 at 09:11, Christophe Saout wrote:
> Hi!
>
> In camel/camel-gpg-context.c (evo 1.3 cvs) there is a problem:
>
> In gpg_ctx_op_step the file descriptors stdout_fd, stderr_fd and
> status_fd are polled for input.
>
> But stdout_fd is not read when there is no gpg->ostream to get the data
> (if (FD_ISSET (gpg->stdout_fd, &rdset) && gpg->ostream)).
>
> So the end of file state cannot be detected and thus gpg->seen_eof1
> won't be set.
>
> If that happens gpg_ctx_op_complete fails to detect when gpg has
> finished and the users of these functions run in an endless loop.
>
> The following (ugly) patch fixes the problem for me:
>
> --- camel-gpg-context.c.orig Mon Apr 21 14:38:57 2003
> +++ camel-gpg-context.c Mon Apr 21 14:44:37 2003
> @@ -969,11 +969,15 @@
>
> retry:
> FD_ZERO (&rdset);
> - FD_SET (gpg->stdout_fd, &rdset);
> + if (gpg->ostream)
> + FD_SET (gpg->stdout_fd, &rdset);
> FD_SET (gpg->stderr_fd, &rdset);
> FD_SET (gpg->status_fd, &rdset);
>
> - maxfd = MAX (gpg->stdout_fd, gpg->stderr_fd);
> + if (gpg->ostream)
> + maxfd = MAX (gpg->stdout_fd, gpg->stderr_fd);
> + else
> + maxfd = gpg->stderr_fd;
> maxfd = MAX (maxfd, gpg->status_fd);
>
> if (gpg->stdin_fd != -1 || gpg->passwd_fd != -1) {
> @@ -1181,7 +1185,7 @@
> static gboolean
> gpg_ctx_op_complete (struct _GpgCtx *gpg)
> {
> - return gpg->complete && gpg->seen_eof1 && gpg->seen_eof2;
> + return gpg->complete && (gpg->seen_eof1 || !gpg->ostream) &&
> gpg->seen_eof2;
> }
>
> static gboolean
--
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com - www.ximian.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]