Solution to the bug appears to be very simple. The patch is attached.
Igor
--- gpgme/wait-global.c.orig 2005-03-25 16:45:14.000000000 -0500 +++ gpgme/wait-global.c 2005-03-25 16:51:40.000000000 -0500 @@ -174,7 +174,10 @@ free (li); } else + { ctx = NULL; + *status = 0; + } UNLOCK (ctx_list_lock); return ctx; } @@ -345,7 +348,7 @@ { gpgme_ctx_t dctx = ctx_wait (ctx, status); - if (dctx) + if (dctx || !hang) { ctx = dctx; hang = 0;