aboutsummaryrefslogtreecommitdiffstats
path: root/scd
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2007-07-04 09:34:28 +0000
committerWerner Koch <[email protected]>2007-07-04 09:34:28 +0000
commitf54b85bc2d9b80f40ee025f74857fb3bb1436f9a (patch)
tree49c49918b0e18b84ab5b242d796e36cdc6215710 /scd
parentMore W32 related changes (diff)
downloadgnupg-f54b85bc2d9b80f40ee025f74857fb3bb1436f9a.tar.gz
gnupg-f54b85bc2d9b80f40ee025f74857fb3bb1436f9a.zip
A bunch of minor changes for Windows.
Diffstat (limited to 'scd')
-rw-r--r--scd/ChangeLog9
-rw-r--r--scd/command.c9
-rw-r--r--scd/scdaemon.c26
3 files changed, 38 insertions, 6 deletions
diff --git a/scd/ChangeLog b/scd/ChangeLog
index 3db91a0f7..5880d8e25 100644
--- a/scd/ChangeLog
+++ b/scd/ChangeLog
@@ -1,3 +1,12 @@
+2007-07-04 Werner Koch <[email protected]>
+
+ * command.c (cmd_getinfo): New subcommand "version".
+
+ * scdaemon.c (TIMERTICK_INTERVAL): New.
+ (handle_connections) [W32]: Enable a dummy sigs event.
+ (handle_connections): Use a proper count for select and not
+ FD_SETSIZE.
+
2007-06-21 Werner Koch <[email protected]>
* scdaemon.h (ctrl_t): Remove. It is now declared in ../common/util.h.
diff --git a/scd/command.c b/scd/command.c
index 3ffa5afb6..fa5a18977 100644
--- a/scd/command.c
+++ b/scd/command.c
@@ -1402,6 +1402,8 @@ cmd_unlock (assuan_context_t ctx, char *line)
Multi purpose command to return certain information.
Supported values of WHAT are:
+ version - Return the version of the program.
+
socket_name - Return the name of the socket.
status - Return the status of the current slot (in the future, may
@@ -1420,7 +1422,12 @@ cmd_getinfo (assuan_context_t ctx, char *line)
{
int rc = 0;
- if (!strcmp (line, "socket_name"))
+ if (!strcmp (line, "version"))
+ {
+ const char *s = VERSION;
+ rc = assuan_send_data (ctx, s, strlen (s));
+ }
+ else if (!strcmp (line, "socket_name"))
{
const char *s = scd_get_socket_name ();
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index b2508943d..8b86f8b7f 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -150,6 +150,15 @@ static ARGPARSE_OPTS opts[] = {
#define DEFAULT_PCSC_DRIVER "libpcsclite.so"
#endif
+/* The timer tick used for housekeeping stuff. For Windows we use a
+ longer period as the SetWaitableTimer seems to signal earlier than
+ the 2 seconds. */
+#ifdef HAVE_W32_SYSTEM
+#define TIMERTICK_INTERVAL (4)
+#else
+#define TIMERTICK_INTERVAL (2) /* Seconds. */
+#endif
+
/* Flag to indicate that a shutdown was requested. */
static int shutdown_pending;
@@ -280,7 +289,7 @@ main (int argc, char **argv )
FILE *configfp = NULL;
char *configname = NULL;
const char *shell;
- unsigned configlineno;
+ unsigned int configlineno;
int parse_debug = 0;
const char *debug_level = NULL;
int default_config =1;
@@ -1040,6 +1049,7 @@ handle_connections (int listen_fd)
fd_set fdset, read_fdset;
int ret;
int fd;
+ int nfd;
tattr = pth_attr_new();
pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0);
@@ -1055,13 +1065,18 @@ handle_connections (int listen_fd)
pth_sigmask (SIG_UNBLOCK, &sigs, NULL);
ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
#else
- ev = NULL;
+ sigs = 0;
+ ev = pth_event (PTH_EVENT_SIGS, &sigs, &signo);
#endif
time_ev = NULL;
FD_ZERO (&fdset);
+ nfd = 0;
if (listen_fd != -1)
- FD_SET (listen_fd, &fdset);
+ {
+ FD_SET (listen_fd, &fdset);
+ nfd = listen_fd;
+ }
for (;;)
{
@@ -1081,7 +1096,8 @@ handle_connections (int listen_fd)
/* Create a timeout event if needed. */
if (!time_ev)
- time_ev = pth_event (PTH_EVENT_TIME, pth_timeout (2, 0));
+ time_ev = pth_event (PTH_EVENT_TIME,
+ pth_timeout (TIMERTICK_INTERVAL, 0));
/* POSIX says that fd_set should be implemented as a structure,
thus a simple assignment is fine to copy the entire set. */
@@ -1089,7 +1105,7 @@ handle_connections (int listen_fd)
if (time_ev)
pth_event_concat (ev, time_ev, NULL);
- ret = pth_select_ev (FD_SETSIZE, &read_fdset, NULL, NULL, NULL, ev);
+ ret = pth_select_ev (nfd+1, &read_fdset, NULL, NULL, NULL, ev);
if (time_ev)
pth_event_isolate (time_ev);