diff options
Diffstat (limited to 'scd')
-rw-r--r-- | scd/ChangeLog | 9 | ||||
-rw-r--r-- | scd/apdu.c | 4 | ||||
-rw-r--r-- | scd/command.c | 10 | ||||
-rw-r--r-- | scd/scdaemon.c | 22 | ||||
-rw-r--r-- | scd/scdaemon.h | 2 |
5 files changed, 29 insertions, 18 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog index 85177e535..b0550cd26 100644 --- a/scd/ChangeLog +++ b/scd/ChangeLog @@ -1,3 +1,12 @@ +2008-10-15 Werner Koch <[email protected]> + + * command.c (scd_command_handler): Return true if there is no more + active session. + * scdaemon.c (start_connection_thread): Set shutdown flag if + requested by command handler. + (main): Make PIPE_SERVER module global. + (handle_connections): Disable listen_fd if a shutdown is pending. + 2008-10-14 Werner Koch <[email protected]> diff --git a/scd/apdu.c b/scd/apdu.c index c0c5c5d3e..274d27b6e 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -2442,11 +2442,7 @@ apdu_open_reader (const char *portstr) pcsc_api_loaded = 1; } -#ifdef NEED_PCSC_WRAPPER - return open_pcsc_reader_wrapped (portstr); -#else return open_pcsc_reader (portstr); -#endif } diff --git a/scd/command.c b/scd/command.c index aabd93c25..7d2515474 100644 --- a/scd/command.c +++ b/scd/command.c @@ -1,6 +1,6 @@ /* command.c - SCdaemon command handler * Copyright (C) 2001, 2002, 2003, 2004, 2005, - * 2007 Free Software Foundation, Inc. + * 2007, 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -1776,8 +1776,9 @@ register_commands (assuan_context_t ctx) /* Startup the server. If FD is given as -1 this is simple pipe - server, otherwise it is a regular server. */ -void + server, otherwise it is a regular server. Returns true if there + are no more active asessions. */ +int scd_command_handler (ctrl_t ctrl, int fd) { int rc; @@ -1872,6 +1873,9 @@ scd_command_handler (ctrl_t ctrl, int fd) /* Release the Assuan context. */ assuan_deinit_server (ctx); + + /* If there are no more sessions return true. */ + return !session_list; } diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 384df51bf..0366703b7 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -1,6 +1,6 @@ /* scdaemon.c - The GnuPG Smartcard Daemon * Copyright (C) 2001, 2002, 2004, 2005, - * 2007 Free Software Foundation, Inc. + * 2007, 2008 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -167,6 +167,9 @@ static int shutdown_pending; /* It is possible that we are currently running under setuid permissions */ static int maybe_setuid = 1; +/* Flag telling whether we are running as a pipe server. */ +static int pipe_server; + /* Name of the communication socket */ static char *socket_name; @@ -304,7 +307,6 @@ main (int argc, char **argv ) int default_config =1; int greeting = 0; int nogreeting = 0; - int pipe_server = 0; int multi_server = 0; int is_daemon = 0; int nodetach = 0; @@ -1027,19 +1029,18 @@ start_connection_thread (void *arg) log_info (_("handler for fd %d started\n"), FD2INT(ctrl->thread_startup.fd)); - scd_command_handler (ctrl, FD2INT(ctrl->thread_startup.fd)); + /* If this is a pipe server, we request a shutdown if the command + hanlder asked for it. With the next ticker event and given that + no other connections are running the shutdown will then + happen. */ + if (scd_command_handler (ctrl, FD2INT(ctrl->thread_startup.fd)) + && pipe_server) + shutdown_pending = 1; if (opt.verbose) log_info (_("handler for fd %d terminated\n"), FD2INT (ctrl->thread_startup.fd)); - /* If this thread is the pipe connection thread, flag that a - shutdown is required. With the next ticker event and given that - no other connections are running the shutdown will then - happen. */ - if (ctrl->thread_startup.fd == GNUPG_INVALID_FD) - shutdown_pending = 1; - scd_deinit_default_ctrl (ctrl); xfree (ctrl); return NULL; @@ -1105,6 +1106,7 @@ handle_connections (int listen_fd) file descriptors to wait for, so that the select will be used to just wait on a signal or timeout event. */ FD_ZERO (&fdset); + listen_fd = -1; } /* Create a timeout event if needed. */ diff --git a/scd/scdaemon.h b/scd/scdaemon.h index 054aaa0f6..c0857e91b 100644 --- a/scd/scdaemon.h +++ b/scd/scdaemon.h @@ -121,7 +121,7 @@ const char *scd_get_socket_name (void); /*-- command.c --*/ void initialize_module_command (void); -void scd_command_handler (ctrl_t, int); +int scd_command_handler (ctrl_t, int); void send_status_info (ctrl_t ctrl, const char *keyword, ...) GNUPG_GCC_A_SENTINEL(1); void scd_update_reader_status_file (void); |