From: Marcus Brinkmann Date: Tue, 11 Jun 2002 18:12:19 +0000 (+0000) Subject: 2002-06-11 Marcus Brinkmann X-Git-Tag: gpgme-0-3-8~28 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=14f16305b0818b3c3e573976d5d83d6ba6b86682;p=gpgme.git 2002-06-11 Marcus Brinkmann * engine-gpgsm.c (_gpgme_gpgsm_release): Close status_cb.fd. (_gpgme_gpgsm_new): Duplicate status file descriptor, so we can use our own close notification mechanism without interfering with assuan. --- diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 20f74bf..7337181 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,10 @@ +2002-06-11 Marcus Brinkmann + + * engine-gpgsm.c (_gpgme_gpgsm_release): Close status_cb.fd. + (_gpgme_gpgsm_new): Duplicate status file descriptor, so we can + use our own close notification mechanism without interfering with + assuan. + 2002-06-11 Werner Koch * gpgme.h: Add GPGME_ATTR_SIG_SUMMARY and the GPGME_SIGSUM_ diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 0fdd07d..3d490d0 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -381,7 +381,17 @@ _gpgme_gpgsm_new (GpgsmObject *r_gpgsm) err = mk_error (General_Error); /* FIXME */ goto leave; } - gpgsm->status_cb.fd = fdlist[0]; + /* We duplicate the file descriptor, so we can close it without + disturbing assuan. Alternatively, we could special case + status_fd and register/unregister it manually as needed, but this + increases code duplication and is more complicated as we can not + use the close notifications etc. */ + gpgsm->status_cb.fd = dup (fdlist[0]); + if (gpgsm->status_cb.fd < 0) + { + err = mk_error (General_Error); /* FIXME */ + goto leave; + } gpgsm->status_cb.dir = 1; gpgsm->status_cb.data = gpgsm; @@ -516,6 +526,8 @@ _gpgme_gpgsm_release (GpgsmObject gpgsm) if (!gpgsm) return; + if (gpgsm->status_cb.fd != -1) + _gpgme_io_close (gpgsm->status_cb.fd); if (gpgsm->input_cb.fd != -1) _gpgme_io_close (gpgsm->input_cb.fd); if (gpgsm->output_cb.fd != -1) diff --git a/gpgme/rungpg.c b/gpgme/rungpg.c index 318e99d..df84ee5 100644 --- a/gpgme/rungpg.c +++ b/gpgme/rungpg.c @@ -1074,6 +1074,9 @@ read_status ( GpgObject gpg ) if ( r->code == STATUS_END_STREAM ) { if (gpg->cmd.used) { + /* XXX We must check if there are any + more fds active after removing this + one. */ (*gpg->io_cbs.remove) (gpg->fd_data_map[gpg->cmd.idx].tag); gpg->cmd.fd = gpg->fd_data_map[gpg->cmd.idx].fd; @@ -1335,6 +1338,8 @@ command_cb (void *opaque, char *buffer, size_t length, size_t *nread) gpg->cmd.fnc (gpg->cmd.fnc_value, 0, value); gpg->cmd.code = 0; /* And sleep again until read_status will wake us up again. */ + /* XXX We must check if there are any more fds active after removing + this one. */ (*gpg->io_cbs.remove) (gpg->fd_data_map[gpg->cmd.idx].tag); gpg->cmd.fd = gpg->fd_data_map[gpg->cmd.idx].fd; gpg->fd_data_map[gpg->cmd.idx].fd = -1;