diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp index 7e5d648fa..e77d8b63a 100644 --- a/indra/llcommon/lltimer.cpp +++ b/indra/llcommon/lltimer.cpp @@ -251,7 +251,7 @@ U64 totalTime() } else { - if (current_clock_count >= gLastTotalTimeClockCount) + if (LL_LIKELY(current_clock_count >= gLastTotalTimeClockCount)) { // No wrapping, we're all okay. gTotalTimeClockCount += current_clock_count - gLastTotalTimeClockCount; diff --git a/indra/llmessage/aicurlthread.cpp b/indra/llmessage/aicurlthread.cpp index ba6fd8507..b624daf61 100644 --- a/indra/llmessage/aicurlthread.cpp +++ b/indra/llmessage/aicurlthread.cpp @@ -1545,8 +1545,8 @@ void AICurlThread::run(void) continue; } // Clock count used for timeouts. - HTTPTimeout::sClockCount = get_clock_count(); - Dout(dc::curl, "HTTPTimeout::sClockCount = " << HTTPTimeout::sClockCount); + HTTPTimeout::sTime_10ms = get_clock_count() * HTTPTimeout::sClockWidth_10ms; + Dout(dc::curl, "HTTPTimeout::sTime_10ms = " << HTTPTimeout::sTime_10ms); if (ready == 0) { multi_handle_w->socket_action(CURL_SOCKET_TIMEOUT, 0); diff --git a/indra/llmessage/aihttptimeout.cpp b/indra/llmessage/aihttptimeout.cpp index 16ed7c170..1f65b94c0 100644 --- a/indra/llmessage/aihttptimeout.cpp +++ b/indra/llmessage/aihttptimeout.cpp @@ -97,8 +97,8 @@ namespace curlthread { // HTTPTimeout //static -F64 const HTTPTimeout::sClockWidth = 1.0 / calc_clock_frequency(); // Time between two clock ticks, in seconds. -U64 HTTPTimeout::sClockCount; // Clock count, set once per select() exit. +F64 const HTTPTimeout::sClockWidth_10ms = 100.0 / calc_clock_frequency(); // Time between two clock ticks, in 10ms units. +U64 HTTPTimeout::sTime_10ms; // Time in 10ms units, set once per select() exit. // CURL-THREAD // This is called when body data was sent to the server socket. @@ -126,7 +126,7 @@ bool HTTPTimeout::data_sent(size_t n, bool finished) // | | void HTTPTimeout::reset_lowspeed(void) { - mLowSpeedClock = sClockCount; + mLowSpeedClock = sTime_10ms; mLowSpeedOn = true; mLastBytesSent = false; // We're just starting! mLastSecond = -1; // This causes lowspeed to initialize the rest. @@ -163,8 +163,8 @@ void HTTPTimeout::upload_finished(void) // We finished uploading (if there was a body to upload at all), so no more transfer rate timeouts. mLowSpeedOn = false; // Timeout if the server doesn't reply quick enough. - mStalled = sClockCount + mPolicy->getReplyDelay() / sClockWidth; - DoutCurl("upload_finished: mStalled set to sClockCount (" << sClockCount << ") + " << (mStalled - sClockCount) << " (" << mPolicy->getReplyDelay() << " seconds)"); + mStalled = sTime_10ms + 100 * mPolicy->getReplyDelay(); + DoutCurl("upload_finished: mStalled set to Time_10ms (" << sTime_10ms << ") + " << (mStalled - sTime_10ms) << " (" << mPolicy->getReplyDelay() << " seconds)"); } // CURL-THREAD @@ -231,8 +231,7 @@ bool HTTPTimeout::lowspeed(size_t bytes, bool finished) // less than low_speed_limit, we abort. // When are we? - S32 second = (sClockCount - mLowSpeedClock) * sClockWidth; - llassert(sClockWidth > 0.0); + S32 second = (sTime_10ms - mLowSpeedClock) / 100; // This REALLY should never happen, but due to another bug it did happened // and caused something so evil and hard to find that... NEVER AGAIN! llassert(second >= 0); @@ -316,8 +315,8 @@ bool HTTPTimeout::lowspeed(size_t bytes, bool finished) // Just give these bytes 4 more seconds to be written to the socket (after which we'll // assume that the 'upload finished' detection failed and we'll wait another ReplyDelay // seconds before finally, actually timing out. - mStalled = sClockCount + 4 / sClockWidth; - DoutCurl("mStalled set to sClockCount (" << sClockCount << ") + " << (mStalled - sClockCount) << " (4 seconds)"); + mStalled = sTime_10ms + 400; // 4 seconds into the future. + DoutCurl("mStalled set to sTime_10ms (" << sTime_10ms << ") + 400 (4 seconds)"); return false; } // The average transfer rate over the passed low_speed_time seconds is too low. Abort the transfer. @@ -369,8 +368,8 @@ bool HTTPTimeout::lowspeed(size_t bytes, bool finished) while(total_bytes >= mintotalbytes); } // If this function isn't called again within max_stall_time seconds, we stalled. - mStalled = sClockCount + max_stall_time / sClockWidth; - DoutCurl("mStalled set to sClockCount (" << sClockCount << ") + " << (mStalled - sClockCount) << " (" << max_stall_time << " seconds)"); + mStalled = sTime_10ms + 100 * max_stall_time; + DoutCurl("mStalled set to sTime_10ms (" << sTime_10ms << ") + " << (mStalled - sTime_10ms) << " (" << max_stall_time << " seconds)"); return false; } diff --git a/indra/llmessage/aihttptimeout.h b/indra/llmessage/aihttptimeout.h index 2c5442075..fc6db9919 100644 --- a/indra/llmessage/aihttptimeout.h +++ b/indra/llmessage/aihttptimeout.h @@ -85,11 +85,11 @@ class HTTPTimeout : public LLRefCount { S32 mLastSecond; // The time at which lowspeed() was last called, in seconds since mLowSpeedClock. S32 mOverwriteSecond; // The second at which the first bucket of this transfer will be overwritten. U32 mTotalBytes; // The sum of all bytes in mBuckets. - U64 mLowSpeedClock; // Clock count at which low speed detection (re)started. - U64 mStalled; // The clock count at which this transaction is considered to be stalling if nothing is transfered anymore. + U64 mLowSpeedClock; // The time (sTime_10ms) at which low speed detection (re)started. + U64 mStalled; // The time (sTime_10ms) at which this transaction is considered to be stalling if nothing is transfered anymore. public: - static F64 const sClockWidth; // Time between two clock ticks in seconds. - static U64 sClockCount; // Clock count used as 'now' during one loop of the main loop. + static F64 const sClockWidth_10ms; // Time between two clock ticks in 10 ms units. + static U64 sTime_10ms; // Time since the epoch in 10 ms units. #if defined(CWDEBUG) || defined(DEBUG_CURLIO) ThreadSafeBufferedCurlEasyRequest* mLockObj; #endif @@ -121,7 +121,7 @@ class HTTPTimeout : public LLRefCount { void done(AICurlEasyRequest_wat const& curlEasyRequest_w, CURLcode code); // Returns true when we REALLY timed out. Might call upload_finished heuristically. - bool has_stalled(void) { return mStalled < sClockCount && !maybe_upload_finished(); } + bool has_stalled(void) { return mStalled < sTime_10ms && !maybe_upload_finished(); } // Called from BufferedCurlEasyRequest::processOutput if a timeout occurred. void print_diagnostics(CurlEasyRequest const* curl_easy_request, char const* eff_url);