2008-08-11 Marcus Brinkmann <marcus@g10code.com>
* rungpg.c (gpg_cancel): Remove cmd fd before status fd. * gpgme.c (_gpgme_cancel_with_err): New function. (gpgme_cancel): Reimplement in terms of _gpgme_cancel_with_err. * wait-private.c (_gpgme_wait_on_condition): Use _gpgme_cancel_with_err. * wait-user.c (_gpgme_user_io_cb_handler): Likewise. * wait-global.c (_gpgme_wait_global_event_cb, gpgme_wait): Likewise.
This commit is contained in:
parent
569829b6fd
commit
26c0edc270
@ -1,3 +1,13 @@
|
|||||||
|
2008-08-11 Marcus Brinkmann <marcus@g10code.com>
|
||||||
|
|
||||||
|
* rungpg.c (gpg_cancel): Remove cmd fd before status fd.
|
||||||
|
* gpgme.c (_gpgme_cancel_with_err): New function.
|
||||||
|
(gpgme_cancel): Reimplement in terms of _gpgme_cancel_with_err.
|
||||||
|
* wait-private.c (_gpgme_wait_on_condition): Use
|
||||||
|
_gpgme_cancel_with_err.
|
||||||
|
* wait-user.c (_gpgme_user_io_cb_handler): Likewise.
|
||||||
|
* wait-global.c (_gpgme_wait_global_event_cb, gpgme_wait): Likewise.
|
||||||
|
|
||||||
2008-08-08 Marcus Brinkmann <marcus@g10code.com>
|
2008-08-08 Marcus Brinkmann <marcus@g10code.com>
|
||||||
|
|
||||||
* rungpg.c (command_handler): Remove I/O callback on error, too.
|
* rungpg.c (command_handler): Remove I/O callback on error, too.
|
||||||
|
@ -106,24 +106,31 @@ gpgme_new (gpgme_ctx_t *r_ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Cancel a pending asynchronous operation. */
|
|
||||||
gpgme_error_t
|
gpgme_error_t
|
||||||
gpgme_cancel (gpgme_ctx_t ctx)
|
_gpgme_cancel_with_err (gpgme_ctx_t ctx, gpg_error_t ctx_err)
|
||||||
{
|
{
|
||||||
gpgme_error_t err;
|
gpgme_error_t err;
|
||||||
TRACE_BEG (DEBUG_CTX, "gpgme_cancel", ctx);
|
TRACE_BEG1 (DEBUG_CTX, "_gpgme_cancel_with_err", ctx, "ctx_err=%i",
|
||||||
|
ctx_err);
|
||||||
|
|
||||||
err = _gpgme_engine_cancel (ctx->engine);
|
err = _gpgme_engine_cancel (ctx->engine);
|
||||||
if (err)
|
if (err)
|
||||||
return TRACE_ERR (err);
|
return TRACE_ERR (err);
|
||||||
|
|
||||||
err = gpg_error (GPG_ERR_CANCELED);
|
_gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &ctx_err);
|
||||||
_gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err);
|
|
||||||
|
|
||||||
return TRACE_ERR (0);
|
return TRACE_ERR (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Cancel a pending asynchronous operation. */
|
||||||
|
gpgme_error_t
|
||||||
|
gpgme_cancel (gpgme_ctx_t ctx)
|
||||||
|
{
|
||||||
|
return _gpgme_cancel_with_err (ctx, gpg_error (GPG_ERR_CANCELED));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Cancel a pending operation asynchronously. */
|
/* Cancel a pending operation asynchronously. */
|
||||||
gpgme_error_t
|
gpgme_error_t
|
||||||
gpgme_cancel_async (gpgme_ctx_t ctx)
|
gpgme_cancel_async (gpgme_ctx_t ctx)
|
||||||
|
@ -72,7 +72,7 @@ extern "C" {
|
|||||||
AM_PATH_GPGME macro) check that this header matches the installed
|
AM_PATH_GPGME macro) check that this header matches the installed
|
||||||
library. Warning: Do not edit the next line. configure will do
|
library. Warning: Do not edit the next line. configure will do
|
||||||
that for you! */
|
that for you! */
|
||||||
#define GPGME_VERSION "1.1.7-svn1326"
|
#define GPGME_VERSION "1.1.7-svn1329"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/* From gpgme.c. */
|
/* From gpgme.c. */
|
||||||
|
gpgme_error_t _gpgme_cancel_with_err (gpgme_ctx_t ctx, gpg_error_t ctx_err);
|
||||||
|
|
||||||
void _gpgme_release_result (gpgme_ctx_t ctx);
|
void _gpgme_release_result (gpgme_ctx_t ctx);
|
||||||
|
|
||||||
|
|
||||||
|
@ -340,6 +340,17 @@ gpg_cancel (void *engine)
|
|||||||
if (!gpg)
|
if (!gpg)
|
||||||
return gpg_error (GPG_ERR_INV_VALUE);
|
return gpg_error (GPG_ERR_INV_VALUE);
|
||||||
|
|
||||||
|
/* If gpg may be waiting for a cmd, close the cmd fd first. On
|
||||||
|
Windows, close operations block on the reader/writer thread. */
|
||||||
|
if (gpg->cmd.used)
|
||||||
|
{
|
||||||
|
if (gpg->cmd.fd != -1)
|
||||||
|
_gpgme_io_close (gpg->cmd.fd);
|
||||||
|
else if (gpg->fd_data_map
|
||||||
|
&& gpg->fd_data_map[gpg->cmd.idx].fd != -1)
|
||||||
|
_gpgme_io_close (gpg->fd_data_map[gpg->cmd.idx].fd);
|
||||||
|
}
|
||||||
|
|
||||||
if (gpg->status.fd[0] != -1)
|
if (gpg->status.fd[0] != -1)
|
||||||
_gpgme_io_close (gpg->status.fd[0]);
|
_gpgme_io_close (gpg->status.fd[0]);
|
||||||
if (gpg->status.fd[1] != -1)
|
if (gpg->status.fd[1] != -1)
|
||||||
@ -353,8 +364,6 @@ gpg_cancel (void *engine)
|
|||||||
free_fd_data_map (gpg->fd_data_map);
|
free_fd_data_map (gpg->fd_data_map);
|
||||||
gpg->fd_data_map = NULL;
|
gpg->fd_data_map = NULL;
|
||||||
}
|
}
|
||||||
if (gpg->cmd.fd != -1)
|
|
||||||
_gpgme_io_close (gpg->cmd.fd);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -200,16 +200,9 @@ _gpgme_wait_global_event_cb (void *data, gpgme_event_io_t type,
|
|||||||
gpgme_error_t err = ctx_active (ctx);
|
gpgme_error_t err = ctx_active (ctx);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
{
|
/* An error occured. Close all fds in this context, and
|
||||||
/* An error occured. Close all fds in this context, and
|
send the error in a done event. */
|
||||||
send the error in a done event. */
|
_gpgme_cancel_with_err (ctx, &err);
|
||||||
unsigned int idx;
|
|
||||||
|
|
||||||
for (idx = 0; idx <= ctx->fdt.size; idx++)
|
|
||||||
if (ctx->fdt.fds[idx].fd != -1)
|
|
||||||
_gpgme_io_close (ctx->fdt.fds[idx].fd);
|
|
||||||
_gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -321,13 +314,7 @@ gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang)
|
|||||||
{
|
{
|
||||||
/* An error occured. Close all fds in this context,
|
/* An error occured. Close all fds in this context,
|
||||||
and signal it. */
|
and signal it. */
|
||||||
unsigned int idx;
|
_gpgme_cancel_with_err (ictx, err);
|
||||||
|
|
||||||
for (idx = 0; idx < ictx->fdt.size; idx++)
|
|
||||||
if (ictx->fdt.fds[idx].fd != -1)
|
|
||||||
_gpgme_io_close (ictx->fdt.fds[idx].fd);
|
|
||||||
_gpgme_engine_io_event (ictx->engine, GPGME_EVENT_DONE,
|
|
||||||
&err);
|
|
||||||
|
|
||||||
/* Break out of the loop, and retry the select()
|
/* Break out of the loop, and retry the select()
|
||||||
from scratch, because now all fds should be
|
from scratch, because now all fds should be
|
||||||
|
@ -89,10 +89,7 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond)
|
|||||||
unsigned int idx;
|
unsigned int idx;
|
||||||
|
|
||||||
err = gpg_error_from_errno (errno);
|
err = gpg_error_from_errno (errno);
|
||||||
for (idx = 0; idx < ctx->fdt.size; idx++)
|
_gpgme_cancel_with_err (ctx, err);
|
||||||
if (ctx->fdt.fds[idx].fd != -1)
|
|
||||||
_gpgme_io_close (ctx->fdt.fds[idx].fd);
|
|
||||||
_gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err);
|
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@ -116,12 +113,8 @@ _gpgme_wait_on_condition (gpgme_ctx_t ctx, volatile int *cond)
|
|||||||
{
|
{
|
||||||
/* An error occured. Close all fds in this context,
|
/* An error occured. Close all fds in this context,
|
||||||
and signal it. */
|
and signal it. */
|
||||||
unsigned int idx;
|
_gpgme_cancel_with_err (ctx, err);
|
||||||
|
|
||||||
for (idx = 0; idx < ctx->fdt.size; idx++)
|
|
||||||
if (ctx->fdt.fds[idx].fd != -1)
|
|
||||||
_gpgme_io_close (ctx->fdt.fds[idx].fd);
|
|
||||||
_gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,14 +55,7 @@ _gpgme_user_io_cb_handler (void *data, int fd)
|
|||||||
if (! err)
|
if (! err)
|
||||||
err = _gpgme_run_io_cb (&ctx->fdt.fds[tag->idx], 0);
|
err = _gpgme_run_io_cb (&ctx->fdt.fds[tag->idx], 0);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
_gpgme_cancel_with_err (ctx, err);
|
||||||
unsigned int idx;
|
|
||||||
|
|
||||||
for (idx = 0; idx < ctx->fdt.size; idx++)
|
|
||||||
if (ctx->fdt.fds[idx].fd != -1)
|
|
||||||
_gpgme_io_close (ctx->fdt.fds[idx].fd);
|
|
||||||
_gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &err);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
Loading…
Reference in New Issue
Block a user