|
|
@ -168,15 +168,14 @@ void RandAddSeedPerfmon()
|
|
|
|
#ifdef WIN32
|
|
|
|
#ifdef WIN32
|
|
|
|
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
|
|
|
|
// Don't need this on Linux, OpenSSL automatically uses /dev/urandom
|
|
|
|
// Seed with the entire set of perfmon data
|
|
|
|
// Seed with the entire set of perfmon data
|
|
|
|
unsigned char pdata[250000];
|
|
|
|
std::vector <unsigned char> vData(250000,0);
|
|
|
|
memset(pdata, 0, sizeof(pdata));
|
|
|
|
unsigned long nSize = vData.size();
|
|
|
|
unsigned long nSize = sizeof(pdata);
|
|
|
|
long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, begin_ptr(vData), &nSize);
|
|
|
|
long ret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, pdata, &nSize);
|
|
|
|
|
|
|
|
RegCloseKey(HKEY_PERFORMANCE_DATA);
|
|
|
|
RegCloseKey(HKEY_PERFORMANCE_DATA);
|
|
|
|
if (ret == ERROR_SUCCESS)
|
|
|
|
if (ret == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
RAND_add(pdata, nSize, nSize/100.0);
|
|
|
|
RAND_add(begin_ptr(vData), nSize, nSize/100.0);
|
|
|
|
OPENSSL_cleanse(pdata, nSize);
|
|
|
|
OPENSSL_cleanse(begin_ptr(vData), nSize);
|
|
|
|
LogPrint("rand", "RandAddSeed() %lu bytes\n", nSize);
|
|
|
|
LogPrint("rand", "RandAddSeed() %lu bytes\n", nSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -1141,15 +1140,15 @@ void ShrinkDebugFile()
|
|
|
|
if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000)
|
|
|
|
if (file && boost::filesystem::file_size(pathLog) > 10 * 1000000)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Restart the file with some of the end
|
|
|
|
// Restart the file with some of the end
|
|
|
|
char pch[200000];
|
|
|
|
std::vector <char> vch(200000,0);
|
|
|
|
fseek(file, -sizeof(pch), SEEK_END);
|
|
|
|
fseek(file, -vch.size(), SEEK_END);
|
|
|
|
int nBytes = fread(pch, 1, sizeof(pch), file);
|
|
|
|
int nBytes = fread(begin_ptr(vch), 1, vch.size(), file);
|
|
|
|
fclose(file);
|
|
|
|
fclose(file);
|
|
|
|
|
|
|
|
|
|
|
|
file = fopen(pathLog.string().c_str(), "w");
|
|
|
|
file = fopen(pathLog.string().c_str(), "w");
|
|
|
|
if (file)
|
|
|
|
if (file)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fwrite(pch, 1, nBytes, file);
|
|
|
|
fwrite(begin_ptr(vch), 1, nBytes, file);
|
|
|
|
fclose(file);
|
|
|
|
fclose(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|