aboutsummaryrefslogtreecommitdiffstats
path: root/src/engine-gpg.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2019-06-07 09:17:53 +0000
committerWerner Koch <[email protected]>2019-06-07 09:17:53 +0000
commit52d8ed8dfb91a2b302c20bee27e9a28b7cb6a518 (patch)
tree427ee906e5d794a4aacaceac7fdfaf3dd79eb180 /src/engine-gpg.c
parenttests: Minor fix to run-threaded.c. (diff)
downloadgpgme-52d8ed8dfb91a2b302c20bee27e9a28b7cb6a518.tar.gz
gpgme-52d8ed8dfb91a2b302c20bee27e9a28b7cb6a518.zip
core: Replace the posix close notify mechanism by a new generic one.
* src/fdtable.c, src/fdtable.h: New. * src/posix-io.c (notify_table_item_s): Remove. (notify_table, notify_table_size, notify_table_lock): Remove. (_gpgme_io_pipe): Put new fds into the table. (_gpgme_io_dup): Ditto. (_gpgme_io_close): Replace notify stuff by a call to the fdtable. (_gpgme_io_set_close_notify): Remove. Change all callers to to use _gpgme_fdtable_add_close_notify. * src/Makefile.am (main_sources): Add new files. -- This is the first part or a larger change to unify the tracking of file descriptors. Right now this has only been implemented for Posix and thus the code will not yet build for Windows. Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'src/engine-gpg.c')
-rw-r--r--src/engine-gpg.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/engine-gpg.c b/src/engine-gpg.c
index dc2d9455..cce80d8d 100644
--- a/src/engine-gpg.c
+++ b/src/engine-gpg.c
@@ -173,7 +173,7 @@ gpg_io_event (void *engine, gpgme_event_io_t type, void *type_data)
}
-static void
+static gpg_error_t
close_notify_handler (int fd, void *opaque)
{
engine_gpg_t gpg = opaque;
@@ -217,6 +217,7 @@ close_notify_handler (int fd, void *opaque)
}
}
}
+ return 0;
}
/* If FRONT is true, push at the front of the list. Use this for
@@ -525,10 +526,10 @@ gpg_new (void **engine, const char *file_name, const char *home_dir,
rc = gpg_error_from_syserror ();
goto leave;
}
- if (_gpgme_io_set_close_notify (gpg->status.fd[0],
- close_notify_handler, gpg)
- || _gpgme_io_set_close_notify (gpg->status.fd[1],
- close_notify_handler, gpg))
+ if (_gpgme_fdtable_add_close_notify (gpg->status.fd[0],
+ close_notify_handler, gpg)
+ || _gpgme_fdtable_add_close_notify (gpg->status.fd[1],
+ close_notify_handler, gpg))
{
rc = gpg_error (GPG_ERR_GENERAL);
goto leave;
@@ -778,9 +779,10 @@ gpg_set_colon_line_handler (void *engine, engine_colon_line_handler_t fnc,
gpg->colon.buffer = NULL;
return saved_err;
}
- if (_gpgme_io_set_close_notify (gpg->colon.fd[0], close_notify_handler, gpg)
- || _gpgme_io_set_close_notify (gpg->colon.fd[1],
- close_notify_handler, gpg))
+ if (_gpgme_fdtable_add_close_notify (gpg->colon.fd[0],
+ close_notify_handler, gpg)
+ || _gpgme_fdtable_add_close_notify (gpg->colon.fd[1],
+ close_notify_handler, gpg))
return gpg_error (GPG_ERR_GENERAL);
gpg->colon.eof = 0;
gpg->colon.fnc = fnc;
@@ -1112,11 +1114,11 @@ build_argv (engine_gpg_t gpg, const char *pgmname)
free_argv (argv);
return saved_err;
}
- if (_gpgme_io_set_close_notify (fds[0],
- close_notify_handler, gpg)
- || _gpgme_io_set_close_notify (fds[1],
- close_notify_handler,
- gpg))
+ if (_gpgme_fdtable_add_close_notify (fds[0],
+ close_notify_handler, gpg)
+ || _gpgme_fdtable_add_close_notify (fds[1],
+ close_notify_handler,
+ gpg))
{
/* We leak fd_data_map and the fds. This is not easy
to avoid and given that we reach this here only