Bug 1275306 - Part 1: Use TimeDuration for MAX_TIMEOUT_INTERVAL in the JS shell; r=jandem

This commit is contained in:
Terrence Cole 2016-05-28 16:10:00 +02:00
Родитель d9b5c79aac
Коммит 68a44fc60c
1 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -134,7 +134,7 @@ static const size_t gMaxStackSize = 128 * sizeof(size_t) * 1024;
* Limit the timeout to 30 minutes to prevent an overflow on platfoms
* that represent the time internally in microseconds using 32-bit int.
*/
static const double MAX_TIMEOUT_INTERVAL = 1800.0; // seconds
static const TimeDuration MAX_TIMEOUT_INTERVAL = TimeDuration::FromSeconds(1800.0);
#ifdef NIGHTLY_BUILD
# define SHARED_MEMORY_DEFAULT 1
@ -3126,13 +3126,13 @@ Sleep_fn(JSContext* cx, unsigned argc, Value* vp)
double t_secs;
if (!ToNumber(cx, args[0], &t_secs))
return false;
duration = TimeDuration::FromSeconds(Max(0.0, t_secs));
/* NB: The next condition also filter out NaNs. */
if (!(t_secs <= MAX_TIMEOUT_INTERVAL)) {
if (duration > MAX_TIMEOUT_INTERVAL) {
JS_ReportError(cx, "Excessive sleep interval");
return false;
}
duration = TimeDuration::FromSeconds(Max(0.0, t_secs));
}
PR_Lock(sr->watchdogLock);
TimeStamp toWakeup = TimeStamp::Now() + duration;
@ -3318,7 +3318,7 @@ static bool
SetTimeoutValue(JSContext* cx, double t)
{
/* NB: The next condition also filter out NaNs. */
if (!(t <= MAX_TIMEOUT_INTERVAL)) {
if (TimeDuration::FromSeconds(t) > MAX_TIMEOUT_INTERVAL) {
JS_ReportError(cx, "Excessive timeout value");
return false;
}