summaryrefslogtreecommitdiff
path: root/random
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2010-10-18 10:12:23 +0000
committerWerner Koch <wk@gnupg.org>2010-10-18 10:12:23 +0000
commitf34e11b10099371e861fa417c8336d26c24ad578 (patch)
treedff4f82fea22d5a99a2876e96d736db5ac910ba6 /random
parent2a96302c6688e137d6790219878f6c111e0d27f4 (diff)
downloadlibgcrypt-f34e11b10099371e861fa417c8336d26c24ad578.tar.gz
Look at GNUPG_RNDW32_NOPERF
Diffstat (limited to 'random')
-rw-r--r--random/ChangeLog5
-rw-r--r--random/rndw32.c75
2 files changed, 49 insertions, 31 deletions
diff --git a/random/ChangeLog b/random/ChangeLog
index 9feb32c7..f70f30b4 100644
--- a/random/ChangeLog
+++ b/random/ChangeLog
@@ -1,3 +1,8 @@
+2010-10-18 Werner Koch <wk@g10code.com>
+
+ * rndw32.c (registry_poll): Disable performace fata gathering if
+ GNUPG_RNDW32_NOPERF has been set.
+
2010-04-27 Marcus Brinkmann <marcus@g10code.de>
* rndw32ce.c (fillup_buffer): Rewrite without using nested
diff --git a/random/rndw32.c b/random/rndw32.c
index 852f9aca..c48eba76 100644
--- a/random/rndw32.c
+++ b/random/rndw32.c
@@ -418,45 +418,58 @@ registry_poll (void (*add)(const void*, size_t, enum random_origins),
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)
- {
- if (!memcmp (pPerfData->Signature, L"PERF", 8))
- (*add) ( pPerfData, dwSize, requester );
- else
- log_debug ("rndw32: no PERF signature\n");
- break;
- }
- else if (status == ERROR_MORE_DATA)
+ static int shown;
+
+ if (!shown)
{
- cbPerfData += PERFORMANCE_BUFFER_STEP;
- pPerfData = gcry_xrealloc (pPerfData, cbPerfData);
+ shown = 1;
+ log_info ("note: get performance data has been disabled\n");
}
- else
+ }
+ else
+ {
+ pPerfData = gcry_xmalloc (cbPerfData);
+ for (iterations=0; iterations < 10; iterations++)
{
- 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;
+ }
+ 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;
}
- 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