[glib] switch GSocket to monotonic time for timeouts
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] switch GSocket to monotonic time for timeouts
- Date: Wed, 27 Oct 2010 13:23:09 +0000 (UTC)
commit 83472b34ef0bd3b53ff0a38b7f8691c3bd6fa0a9
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 9ff3597..637dcd4 100644
--- a/gio/gsocket.c
+++ b/gio/gsocket.c
@@ -2411,7 +2411,7 @@ typedef struct {
GIOCondition condition;
GCancellable *cancellable;
GPollFD cancel_pollfd;
- GTimeVal timeout_time;
+ GTimeSpec timeout_time;
} GSocketSource;
static gboolean
@@ -2425,11 +2425,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;
@@ -2547,13 +2547,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]