2002-06-14 Marcus Brinkmann <marcus@g10code.de>
* wait.c (do_select): Return -1 on error, and 0 if nothing to run. (_gpgme_wait_one): Only set HANG to zero if do_select returned an error, or there are no more file descriptors to wait on. (_gpgme_wait_on_condition): Ignore return value from do_select for now.
This commit is contained in:
parent
2fe7046d15
commit
ccde48c08d
@ -1,3 +1,11 @@
|
|||||||
|
2002-06-14 Marcus Brinkmann <marcus@g10code.de>
|
||||||
|
|
||||||
|
* wait.c (do_select): Return -1 on error, and 0 if nothing to run.
|
||||||
|
(_gpgme_wait_one): Only set HANG to zero if do_select returned an
|
||||||
|
error, or there are no more file descriptors to wait on.
|
||||||
|
(_gpgme_wait_on_condition): Ignore return value from do_select for
|
||||||
|
now.
|
||||||
|
|
||||||
2002-06-13 Werner Koch <wk@gnupg.org>
|
2002-06-13 Werner Koch <wk@gnupg.org>
|
||||||
|
|
||||||
* verify.c (gpgme_op_verify): Make sure that we never access an
|
* verify.c (gpgme_op_verify): Make sure that we never access an
|
||||||
|
38
gpgme/wait.c
38
gpgme/wait.c
@ -143,8 +143,8 @@ run_idle ()
|
|||||||
|
|
||||||
|
|
||||||
/* Wait on all file descriptors listed in FDT and process them using
|
/* Wait on all file descriptors listed in FDT and process them using
|
||||||
the registered callbacks. Returns 0 if nothing to run and 1 if it
|
the registered callbacks. Returns -1 on error (with errno set), 0
|
||||||
did run something. */
|
if nothing to run and 1 if it did run something. */
|
||||||
static int
|
static int
|
||||||
do_select (fd_table_t fdt)
|
do_select (fd_table_t fdt)
|
||||||
{
|
{
|
||||||
@ -157,7 +157,7 @@ do_select (fd_table_t fdt)
|
|||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
{
|
{
|
||||||
UNLOCK (fdt->lock);
|
UNLOCK (fdt->lock);
|
||||||
return 0; /* Error or timeout. */
|
return n; /* Error or timeout. */
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < fdt->size && n; i++)
|
for (i = 0; i < fdt->size && n; i++)
|
||||||
@ -236,22 +236,44 @@ gpgme_wait (GpgmeCtx ctx, GpgmeError *status, int hang)
|
|||||||
GpgmeError
|
GpgmeError
|
||||||
_gpgme_wait_one (GpgmeCtx ctx)
|
_gpgme_wait_one (GpgmeCtx ctx)
|
||||||
{
|
{
|
||||||
|
GpgmeError err = 0;
|
||||||
int hang = 1;
|
int hang = 1;
|
||||||
DEBUG1 ("waiting... ctx=%p", ctx);
|
DEBUG1 ("waiting... ctx=%p", ctx);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (! do_select (&ctx->fdt))
|
if (do_select (&ctx->fdt) < 0)
|
||||||
|
{
|
||||||
|
err = mk_error (File_Error);
|
||||||
hang = 0;
|
hang = 0;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int any = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
LOCK (ctx->fdt.lock);
|
||||||
|
for (i = 0; i < ctx->fdt.size; i++)
|
||||||
|
{
|
||||||
|
if (ctx->fdt.fds[i].fd != -1)
|
||||||
|
{
|
||||||
|
any = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!any)
|
||||||
|
hang = 0;
|
||||||
|
UNLOCK (ctx->fdt.lock);
|
||||||
|
}
|
||||||
|
}
|
||||||
while (hang && !ctx->cancel);
|
while (hang && !ctx->cancel);
|
||||||
if (ctx->cancel)
|
if (!err && ctx->cancel)
|
||||||
{
|
{
|
||||||
/* FIXME: Paranoia? */
|
/* FIXME: Paranoia? */
|
||||||
ctx->cancel = 0;
|
ctx->cancel = 0;
|
||||||
ctx->pending = 0;
|
ctx->pending = 0;
|
||||||
ctx->error = mk_error (Canceled);
|
ctx->error = mk_error (Canceled);
|
||||||
}
|
}
|
||||||
return ctx->error;
|
return err ? err : ctx->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -261,8 +283,8 @@ _gpgme_wait_on_condition (GpgmeCtx ctx, int hang, volatile int *cond)
|
|||||||
DEBUG3 ("waiting... ctx=%p hang=%d cond=%p", ctx, hang, cond);
|
DEBUG3 ("waiting... ctx=%p hang=%d cond=%p", ctx, hang, cond);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (! do_select (&fdt_global))
|
/* XXX We are ignoring all errors from select here. */
|
||||||
hang = 0;
|
do_select (&fdt_global);
|
||||||
|
|
||||||
if (cond && *cond)
|
if (cond && *cond)
|
||||||
hang = 0;
|
hang = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user