[svn] gcry - r1447 - trunk/random

svn author wk cvs at cvs.gnupg.org
Mon Oct 18 12:12:24 CEST 2010


Author: wk
Date: 2010-10-18 12:12:23 +0200 (Mon, 18 Oct 2010)
New Revision: 1447

Modified:
   trunk/random/ChangeLog
   trunk/random/rndw32.c
Log:
Look at GNUPG_RNDW32_NOPERF


Modified: trunk/random/ChangeLog
===================================================================
--- trunk/random/ChangeLog	2010-08-31 16:43:44 UTC (rev 1446)
+++ trunk/random/ChangeLog	2010-10-18 10:12:23 UTC (rev 1447)
@@ -1,3 +1,8 @@
+2010-10-18  Werner Koch  <wk at g10code.com>
+
+	* rndw32.c (registry_poll): Disable performace fata gathering if
+	GNUPG_RNDW32_NOPERF has been set.
+
 2010-04-27  Marcus Brinkmann  <marcus at g10code.de>
 
 	* rndw32ce.c (fillup_buffer): Rewrite without using nested

Modified: trunk/random/rndw32.c
===================================================================
--- trunk/random/rndw32.c	2010-08-31 16:43:44 UTC (rev 1446)
+++ trunk/random/rndw32.c	2010-10-18 10:12:23 UTC (rev 1447)
@@ -418,45 +418,58 @@
      this can consume tens of MB of memory and huge amounts of CPU time
      while it gathers its data, and even running once can still consume
      about 1/2MB of memory */
-  pPerfData = gcry_xmalloc (cbPerfData);
-  for (iterations=0; iterations < 10; iterations++)
+  if (getenv ("GNUPG_RNDW32_NOPERF"))
     {
-      dwSize = cbPerfData;
-      if ( debug_me )
-        log_debug ("rndw32#slow_gatherer_nt: get perf data\n" );
-
-      status = RegQueryValueEx (HKEY_PERFORMANCE_DATA, "Global", NULL,
-                                NULL, (LPBYTE) pPerfData, &dwSize);
-      if (status == ERROR_SUCCESS)
+      static int shown;
+      
+      if (!shown)
         {
-          if (!memcmp (pPerfData->Signature, L"PERF", 8))
-            (*add) ( pPerfData, dwSize, requester );
-          else
-            log_debug ("rndw32: no PERF signature\n");
-          break;
+          shown = 1;
+          log_info ("note: get performance data has been disabled\n");
         }
-      else if (status == ERROR_MORE_DATA)
+    }
+  else
+    {
+      pPerfData = gcry_xmalloc (cbPerfData);
+      for (iterations=0; iterations < 10; iterations++)
         {
-          cbPerfData += PERFORMANCE_BUFFER_STEP;
-          pPerfData = gcry_xrealloc (pPerfData, cbPerfData);
-        }
-      else
-        {
-          static int been_here;
-
-          /* Silence the error message.  In particular under Wine (as
-             of 2008) we would get swamped with such diagnotiscs.  One
-             such diagnotiscs should be enough.  */
-          if (been_here != status)
+          dwSize = cbPerfData;
+          if ( debug_me )
+            log_debug ("rndw32#slow_gatherer_nt: get perf data\n" );
+          
+          status = RegQueryValueEx (HKEY_PERFORMANCE_DATA, "Global", NULL,
+                                    NULL, (LPBYTE) pPerfData, &dwSize);
+          if (status == ERROR_SUCCESS)
             {
-              been_here = status;
-              log_debug ("rndw32: get performance data problem: ec=%ld\n",
-                         status);
+              if (!memcmp (pPerfData->Signature, L"PERF", 8))
+                (*add) ( pPerfData, dwSize, requester );
+              else
+                log_debug ("rndw32: no PERF signature\n");
+              break;
             }
-          break;
+          else if (status == ERROR_MORE_DATA)
+            {
+              cbPerfData += PERFORMANCE_BUFFER_STEP;
+              pPerfData = gcry_xrealloc (pPerfData, cbPerfData);
+            }
+          else
+            {
+              static int been_here;
+              
+              /* Silence the error message.  In particular under Wine (as
+                 of 2008) we would get swamped with such diagnotiscs.  One
+                 such diagnotiscs should be enough.  */
+              if (been_here != status)
+                {
+                  been_here = status;
+                  log_debug ("rndw32: get performance data problem: ec=%ld\n",
+                             status);
+                }
+              break;
+            }
         }
+      gcry_free (pPerfData);
     }
-  gcry_free (pPerfData);
 
   /* Although this isn't documented in the Win32 API docs, it's necessary
      to explicitly close the HKEY_PERFORMANCE_DATA key after use (it's





More information about the Gnupg-commits mailing list