Skip to content

Commit

Permalink
Merge pull request #926 from gmaxwell/master
Browse files Browse the repository at this point in the history
Resolves issue #922 - "wallet passphrase timeout of several years doesn't work"
  • Loading branch information
sipa committed Mar 12, 2012
2 parents 4585d82 + 82a10c8 commit 336ba31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/bitcoinrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 336ba31

Please sign in to comment.