delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/04/14/11:20:24

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Philip Aston" <philipa AT mail DOT com>
Message-ID: <15550.18614.693743.670347@lineone.net>
Date: Thu, 18 Apr 2002 05:16:54 +0100
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: gettime time travels after suspend
References: <15561 DOT 26590 DOT 782158 DOT 717023 AT lineone DOT net>

How about the attached quick and dirty fix?

- Phil



2002-04-14  Philip Aston  <philipa AT mail DOT com>

	* times.cc (hires::usecs): Sync counter every ten minutes to
	work around suspend bug.



Index: cygwin/times.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/times.cc,v
retrieving revision 1.30
diff -u -u -p -r1.30 times.cc
--- cygwin/times.cc	28 Mar 2002 05:20:53 -0000	1.30
+++ cygwin/times.cc	14 Apr 2002 15:09:04 -0000
@@ -599,5 +599,14 @@ hires::usecs (bool justdelta)
 
   // FIXME: Use round() here?
   now.QuadPart = (LONGLONG) (freq * (double) (now.QuadPart - primed_pc.QuadPart));
+
+  /* Reinitialise every ten minutes. Cheap hack to correct time after
+     suspend and resume. */
+  if (now.QuadPart > 600000000l)
+    {
+      inited = 0;
+      return usecs(justdelta);
+    }
+
   return justdelta ? now.QuadPart : primed_ft.QuadPart + now.QuadPart;
 }


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019