mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
dirmngr: Add a background task framework.
* dirmngr/workqueue.c: New. * dirmngr/Makefile.am (dirmngr_SOURCES): Add new file. * dirmngr/server.c (server_local_s): New field session_id. (cmd_wkd_get): Add a task. (task_check_wkd_support): New stub function. (cmd_getinfo): New sub-commands "session_id" and "workqueue". (start_command_handler): Add arg session_id and store it in SERVER_LOCAL. (dirmngr_status_helpf): New. * dirmngr/dirmngr.h (wqtask_t): New type. * dirmngr/dirmngr.c (main): Pass 0 as session_id to start_command_handler. (start_connection_thread): Introduce a session_id and pass it to start_command_handler. Run post session tasks. (housekeeping_thread): Run global workqueue tasks. -- Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
parent
26f08343fb
commit
96a4fbecd1
5 changed files with 305 additions and 12 deletions
|
@ -1134,7 +1134,7 @@ main (int argc, char **argv)
|
|||
cert_cache_init (hkp_cacert_filenames);
|
||||
crl_cache_init ();
|
||||
http_register_netactivity_cb (netactivity_action);
|
||||
start_command_handler (ASSUAN_INVALID_FD);
|
||||
start_command_handler (ASSUAN_INVALID_FD, 0);
|
||||
shutdown_reaper ();
|
||||
}
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
|
@ -1939,7 +1939,10 @@ housekeeping_thread (void *arg)
|
|||
network_activity_seen = 0;
|
||||
if (opt.allow_version_check)
|
||||
dirmngr_load_swdb (&ctrlbuf, 0);
|
||||
workqueue_run_global_tasks (&ctrlbuf, 1);
|
||||
}
|
||||
else
|
||||
workqueue_run_global_tasks (&ctrlbuf, 0);
|
||||
|
||||
dirmngr_deinit_default_ctrl (&ctrlbuf);
|
||||
|
||||
|
@ -2034,6 +2037,8 @@ check_nonce (assuan_fd_t fd, assuan_sock_nonce_t *nonce)
|
|||
static void *
|
||||
start_connection_thread (void *arg)
|
||||
{
|
||||
static unsigned int last_session_id;
|
||||
unsigned int session_id;
|
||||
union int_and_ptr_u argval;
|
||||
gnupg_fd_t fd;
|
||||
|
||||
|
@ -2055,12 +2060,17 @@ start_connection_thread (void *arg)
|
|||
if (opt.verbose)
|
||||
log_info (_("handler for fd %d started\n"), FD2INT (fd));
|
||||
|
||||
start_command_handler (fd);
|
||||
session_id = ++last_session_id;
|
||||
if (!session_id)
|
||||
session_id = ++last_session_id;
|
||||
start_command_handler (fd, session_id);
|
||||
|
||||
if (opt.verbose)
|
||||
log_info (_("handler for fd %d terminated\n"), FD2INT (fd));
|
||||
active_connections--;
|
||||
|
||||
workqueue_run_post_session_tasks (session_id);
|
||||
|
||||
#ifndef HAVE_W32_SYSTEM
|
||||
argval.afd = ASSUAN_INVALID_FD;
|
||||
npth_setspecific (my_tlskey_current_fd, argval.aptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue