[glib/wip/monotonic: 8/9] switch GSocket to monotonic time for timeouts



commit 7ad39db02e51e6bb5cbcfeed8373f3a1d6b318ca
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Oct 22 19:16:57 2010 +0200

    switch GSocket to monotonic time for timeouts

 gio/gsocket.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/gio/gsocket.c b/gio/gsocket.c
index dbedc37..781d770 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -2390,7 +2390,7 @@ typedef struct {
   GIOCondition  condition;
   GCancellable *cancellable;
   GPollFD       cancel_pollfd;
-  GTimeVal      timeout_time;
+  GTimeSpec     timeout_time;
 } GSocketSource;
 
 static gboolean
@@ -2404,11 +2404,11 @@ socket_source_prepare (GSource *source,
 
   if (socket_source->timeout_time.tv_sec)
     {
-      GTimeVal now;
+      GTimeSpec now;
 
-      g_source_get_current_time (source, &now);
+      g_source_get_time (source, &now);
       *timeout = ((socket_source->timeout_time.tv_sec - now.tv_sec) * 1000 +
-		  (socket_source->timeout_time.tv_usec - now.tv_usec) / 1000);
+		  (socket_source->timeout_time.tv_nsec - now.tv_nsec) / 1000000);
       if (*timeout < 0)
 	{
 	  socket_source->socket->priv->timed_out = TRUE;
@@ -2526,13 +2526,13 @@ socket_source_new (GSocket      *socket,
 
   if (socket->priv->timeout)
     {
-      g_get_current_time (&socket_source->timeout_time);
+      g_get_monotonic_time (&socket_source->timeout_time);
       socket_source->timeout_time.tv_sec += socket->priv->timeout;
     }
   else
     {
       socket_source->timeout_time.tv_sec = 0;
-      socket_source->timeout_time.tv_usec = 0;
+      socket_source->timeout_time.tv_nsec = 0;
     }
 
   return source;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]