Ver código fonte

2010-04-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Added warning for the system which lacks clock_gettime with
	CLOCK_MONOTONIC.
	* src/MultiUrlRequestInfo.cc
	* src/TimerA2.cc
	* src/TimerA2.h
Tatsuhiro Tsujikawa 15 anos atrás
pai
commit
473d1ff6b5
4 arquivos alterados com 21 adições e 0 exclusões
  1. 8 0
      ChangeLog
  2. 4 0
      src/MultiUrlRequestInfo.cc
  3. 5 0
      src/TimerA2.cc
  4. 4 0
      src/TimerA2.h

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2010-04-12  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Added warning for the system which lacks clock_gettime with
+	CLOCK_MONOTONIC.
+	* src/MultiUrlRequestInfo.cc
+	* src/TimerA2.cc
+	* src/TimerA2.h
+
 2010-04-12  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Removed redundant method call for DownloadEngine.

+ 4 - 0
src/MultiUrlRequestInfo.cc

@@ -158,6 +158,10 @@ downloadresultcode::RESULT MultiUrlRequestInfo::execute()
     }
     SocketCore::setTLSContext(tlsContext);
 #endif
+    if(!Timer::monotonicClock()) {
+      _logger->warn("Don't change system time while aria2c is running."
+                    " Doing this may make aria2c hang for long time.");
+    }
 
     std::string serverStatIf = _option->get(PREF_SERVER_STAT_IF);
     if(!serverStatIf.empty()) {

+ 5 - 0
src/TimerA2.cc

@@ -162,4 +162,9 @@ void Timer::advance(time_t sec)
   _tv.tv_sec += sec;
 }
 
+bool Timer::monotonicClock()
+{
+  return useClockGettime();
+}
+
 } // namespace aria2

+ 4 - 0
src/TimerA2.h

@@ -94,6 +94,10 @@ public:
   int64_t getTimeInMicros() const;
 
   int64_t getTimeInMillis() const;
+
+  // Returns true if this Timer is not affected by system time change.
+  // Otherwise return false.
+  static bool monotonicClock();
 };
 
 } // namespace aria2