aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-03-11 18:41:00 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2012-03-11 18:41:00 -0700
commit336ba312a6ddc08f40ce456bfd09f0711bdc78dc (patch)
tree7629dc24efea6c45289478741b4b01b60128c7d6
parent4585d828b490f826cf863353d1cdf41ec4cb0724 (diff)
parent82a10c81707dcff5ee24dec7ef7ebf8eccfded03 (diff)
Merge pull request #926 from gmaxwell/master
Resolves issue #922 - "wallet passphrase timeout of several years doesn't work"
-rw-r--r--src/bitcoinrpc.cpp6
-rw-r--r--src/util.h4
2 files changed, 6 insertions, 4 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 68cc17b518..5571c344a3 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -1548,7 +1548,7 @@ void ThreadTopUpKeyPool(void* parg)
void ThreadCleanWalletPassphrase(void* parg)
{
- int64 nMyWakeTime = GetTimeMillis() + *((int*)parg) * 1000;
+ int64 nMyWakeTime = GetTimeMillis() + *((int64*)parg) * 1000;
ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime);
@@ -1584,7 +1584,7 @@ void ThreadCleanWalletPassphrase(void* parg)
LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime);
- delete (int*)parg;
+ delete (int64*)parg;
}
Value walletpassphrase(const Array& params, bool fHelp)
@@ -1619,7 +1619,7 @@ Value walletpassphrase(const Array& params, bool fHelp)
"Stores the wallet decryption key in memory for <timeout> seconds.");
CreateThread(ThreadTopUpKeyPool, NULL);
- int* pnSleepTime = new int(params[1].get_int());
+ int64* pnSleepTime = new int64(params[1].get_int64());
CreateThread(ThreadCleanWalletPassphrase, pnSleepTime);
return Value::null;
diff --git a/src/util.h b/src/util.h
index 31d3275290..d5e8a71cd0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -88,7 +88,9 @@ T* alignup(T* p)
#define Beep(n1,n2) (0)
inline void Sleep(int64 n)
{
- boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n));
+ /*Boost has a year 2038 problem— if the request sleep time is past epoch+2^31 seconds the sleep returns instantly.
+ So we clamp our sleeps here to 10 years and hope that boost is fixed by 2028.*/
+ boost::thread::sleep(boost::get_system_time() + boost::posix_time::milliseconds(n>315576000000LL?315576000000LL:n));
}
#endif