[svn] GnuPG - r4888 - in trunk: agent doc scd

svn author wk cvs at cvs.gnupg.org
Mon Dec 8 20:10:42 CET 2008


Author: wk
Date: 2008-12-08 20:10:42 +0100 (Mon, 08 Dec 2008)
New Revision: 4888

Modified:
   trunk/agent/ChangeLog
   trunk/agent/gpg-agent.c
   trunk/doc/gpg.texi
   trunk/scd/ChangeLog
   trunk/scd/scdaemon.c
Log:
Align ticker to the full or half second.


Modified: trunk/agent/ChangeLog
===================================================================
--- trunk/agent/ChangeLog	2008-12-08 17:11:26 UTC (rev 4887)
+++ trunk/agent/ChangeLog	2008-12-08 19:10:42 UTC (rev 4888)
@@ -1,3 +1,8 @@
+2008-12-08  Werner Koch  <wk at g10code.com>
+
+	* gpg-agent.c (handle_connections): Sync the ticker to the next
+	full second.  This is bug#871.
+
 2008-12-05  Werner Koch  <wk at g10code.com>
 
 	* minip12.c (decrypt_block): Fix const modified of CHARSETS.

Modified: trunk/scd/ChangeLog
===================================================================
--- trunk/scd/ChangeLog	2008-12-08 17:11:26 UTC (rev 4887)
+++ trunk/scd/ChangeLog	2008-12-08 19:10:42 UTC (rev 4888)
@@ -1,3 +1,9 @@
+2008-12-08  Werner Koch  <wk at g10code.com>
+
+	* scdaemon.c (handle_connections): Sync ticker to the next full
+	interval.
+	(TIMERTICK_INTERVAL_USEC): Change to 500ms.
+
 2008-12-05  Werner Koch  <wk at g10code.com>
 
 	* app-openpgp.c (app_local_s): Add field ALGO_ATTR_CHANGE.

Modified: trunk/agent/gpg-agent.c
===================================================================
--- trunk/agent/gpg-agent.c	2008-12-08 17:11:26 UTC (rev 4887)
+++ trunk/agent/gpg-agent.c	2008-12-08 19:10:42 UTC (rev 4888)
@@ -1794,11 +1794,21 @@
           FD_ZERO (&fdset);
 	}
 
-      /* Create a timeout event if needed. */
+      /* Create a timeout event if needed.  To help with power saving
+         we syncronize the ticks to the next full second.  */
       if (!time_ev)
-        time_ev = pth_event (PTH_EVENT_TIME, 
-                             pth_timeout (TIMERTICK_INTERVAL, 0));
+        {
+          pth_time_t nexttick;
 
+          nexttick = pth_timeout (TIMERTICK_INTERVAL, 0);
+          if (nexttick.tv_usec > 10)  /* Use a 10 usec threshhold.  */
+            {
+              nexttick.tv_sec++;
+              nexttick.tv_usec = 0;
+            }
+          time_ev = pth_event (PTH_EVENT_TIME, nexttick);
+        }
+
       /* POSIX says that fd_set should be implemented as a structure,
          thus a simple assignment is fine to copy the entire set.  */
       read_fdset = fdset;

Modified: trunk/doc/gpg.texi
===================================================================
--- trunk/doc/gpg.texi	2008-12-08 17:11:26 UTC (rev 4887)
+++ trunk/doc/gpg.texi	2008-12-08 19:10:42 UTC (rev 4888)
@@ -226,8 +226,8 @@
 @item --decrypt
 @itemx -d
 @opindex decrypt
-Decrypt the file given on the command line (or @code{stdin} if no file
-is specified) and write it to stdout (or the file specified with
+Decrypt the file given on the command line (or STDIN if no file
+is specified) and write it to STDOUT (or the file specified with
 @option{--output}). If the decrypted file is signed, the signature is also
 verified. This command differs from the default operation, as it never
 writes to the filename which is included in the file and it rejects
@@ -237,19 +237,19 @@
 @opindex verify
 Assume that the first argument is a signed file or a detached signature
 and verify it without generating any output. With no arguments, the
-signature packet is read from stdin. If only a sigfile is given, it may
+signature packet is read from STDIN. If only a sigfile is given, it may
 be a complete signature or a detached signature, in which case the
 signed stuff is expected in a file without the ".sig" or ".asc"
 extension.  With more than 1 argument, the first should be a detached
 signature and the remaining files are the signed stuff. To read the
-signed stuff from stdin, use @samp{-} as the second filename.  For
+signed stuff from STDIN, use @samp{-} as the second filename.  For
 security reasons a detached signature cannot read the signed material
-from stdin without denoting it in the above way.
+from STDIN without denoting it in the above way.
 
 @item --multifile
 @opindex multifile
 This modifies certain other commands to accept multiple files for
-processing on the command line or read from stdin with each filename on
+processing on the command line or read from STDIN with each filename on
 a separate line. This allows for many files to be processed at
 once. @option{--multifile} may currently be used along with
 @option{--verify}, @option{--encrypt}, and @option{--decrypt}. Note that
@@ -394,7 +394,7 @@
 @opindex export
 Either export all keys from all keyrings (default keyrings and those
 registered via option @option{--keyring}), or if at least one name is given,
-those of the given name. The new keyring is written to stdout or to the
+those of the given name. The new keyring is written to STDOUT or to the
 file given with option @option{--output}. Use together with
 @option{--armor} to mail those keys.
 
@@ -487,14 +487,14 @@
 
 @item --export-ownertrust
 @opindex export-ownertrust
-Send the ownertrust values to stdout. This is useful for backup purposes
+Send the ownertrust values to STDOUT. This is useful for backup purposes
 as these values are the only ones which can't be re-created from a
 corrupted trust DB.
 
 @item --import-ownertrust
 @opindex import-ownertrust
 Update the trustdb with the ownertrust values stored in @code{files} (or
-stdin if not given); existing values will be overwritten.
+STDIN if not given); existing values will be overwritten.
 
 @item --rebuild-keydb-caches
 @opindex rebuild-keydb-caches
@@ -505,7 +505,7 @@
 @item --print-md @code{algo}
 @itemx --print-mds
 @opindex print-md
-Print message digest of algorithm ALGO for all given files or stdin.
+Print message digest of algorithm ALGO for all given files or STDIN.
 With the second form (or a deprecated "*" as algo) digests for all
 available algorithms are printed.
 
@@ -957,7 +957,12 @@
 @opindex batch
 @opindex no-batch
 Use batch mode.  Never ask, do not allow interactive commands.
- at option{--no-batch} disables this option.
+ at option{--no-batch} disables this option.  Note that even with a
+filename given on the command line, gpg might still need to read from
+STDIN (in particular if gpg figures that the input is a
+detached signature and no data file has been specified).  Thus if you
+do not want to feed data via STDIN, you should connect STDIN to
+ at file{/dev/null}.
 
 @item --no-tty
 @opindex no-tty
@@ -1104,7 +1109,7 @@
 then the photo will be supplied to the viewer on standard input.
 
 The default viewer is "xloadimage -fork -quiet -title 'KeyID 0x%k'
-stdin". Note that if your image viewer program is not secure, then
+STDIN". Note that if your image viewer program is not secure, then
 executing it from GnuPG does not make it secure.
 
 @item --exec-path @code{string}
@@ -2118,7 +2123,7 @@
 @code{file}.
 
 @item --logger-fd @code{n}
-Write log output to file descriptor @code{n} and not to stderr.
+Write log output to file descriptor @code{n} and not to STDERR.
 
 @item --log-file @code{file}
 @itemx --logger-file @code{file}
@@ -2310,7 +2315,7 @@
 @item --passphrase-fd @code{n}
 Read the passphrase from file descriptor @code{n}. Only the first line
 will be read from file descriptor @code{n}. If you use 0 for @code{n},
-the passphrase will be read from stdin. This can only be used if only
+the passphrase will be read from STDIN. This can only be used if only
 one passphrase is supplied.
 @ifclear gpgone
 Note that this passphrase is only used if the option @option{--batch}
@@ -2771,7 +2776,7 @@
 
 If you are going to verify detached signatures, make sure that the
 program knows about it; either give both filenames on the command line
-or use @samp{-} to specify stdin.
+or use @samp{-} to specify STDIN.
 
 @mansect interoperability
 @chapheading INTEROPERABILITY WITH OTHER OPENPGP PROGRAMS

Modified: trunk/scd/scdaemon.c
===================================================================
--- trunk/scd/scdaemon.c	2008-12-08 17:11:26 UTC (rev 4887)
+++ trunk/scd/scdaemon.c	2008-12-08 19:10:42 UTC (rev 4888)
@@ -156,7 +156,7 @@
 #define DEFAULT_PCSC_DRIVER "libpcsclite.so"
 #endif
 
-/* The timer tick used for housekeeping stuff.  We poll every 250ms to
+/* The timer tick used for housekeeping stuff.  We poll every 500ms to
    let the user immediately know a status change.
 
    This is not too good for power saving but given that there is no
@@ -167,7 +167,7 @@
    mechanism.  Given that a native thread could only be used under W32
    we don't do that at all.  */
 #define TIMERTICK_INTERVAL_SEC     (0)
-#define TIMERTICK_INTERVAL_USEC    (250000)
+#define TIMERTICK_INTERVAL_USEC    (500000)
 
 /* Flag to indicate that a shutdown was requested. */
 static int shutdown_pending;
@@ -1152,11 +1152,25 @@
           listen_fd = -1;
 	}
 
-      /* Create a timeout event if needed. */
+      /* Create a timeout event if needed.  Round it up to the next
+         microsecond interval to help with power saving. */
       if (!time_ev)
-        time_ev = pth_event (PTH_EVENT_TIME,
-                             pth_timeout (TIMERTICK_INTERVAL_SEC,
-                                          TIMERTICK_INTERVAL_USEC));
+        {
+          pth_time_t nexttick = pth_timeout (TIMERTICK_INTERVAL_SEC,
+                                             TIMERTICK_INTERVAL_USEC/2);
+          if ((nexttick.tv_usec % (TIMERTICK_INTERVAL_USEC/2)) > 10)
+            {
+              nexttick.tv_usec = ((nexttick.tv_usec
+                                   /(TIMERTICK_INTERVAL_USEC/2))
+                                  + 1) * (TIMERTICK_INTERVAL_USEC/2);
+              if (nexttick.tv_usec >= 1000000)
+                {
+                  nexttick.tv_sec++;
+                  nexttick.tv_usec = 0;
+                }
+            }
+          time_ev = pth_event (PTH_EVENT_TIME, nexttick);
+        }
 
       /* POSIX says that fd_set should be implemented as a structure,
          thus a simple assignment is fine to copy the entire set.  */




More information about the Gnupg-commits mailing list