[at-spi2-core] Fix check for message timeout
- From: Mike Gorse <mgorse src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [at-spi2-core] Fix check for message timeout
- Date: Sun, 30 Jan 2011 17:48:07 +0000 (UTC)
commit 047b023b3c0437c6e15493df4e2433842fd761e3
Author: Mike Gorse <mgorse novell com>
Date: Sun Jan 30 11:50:38 2011 -0600
Fix check for message timeout
dbind/dbind.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/dbind/dbind.c b/dbind/dbind.c
index 23046f2..084de28 100644
--- a/dbind/dbind.c
+++ b/dbind/dbind.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdarg.h>
+#include <sys/time.h>
#include <glib.h>
#include "config.h"
@@ -30,6 +31,15 @@ set_reply (DBusPendingCall * pending, void *user_data)
dbus_pending_call_unref (pending);
}
+static gint
+time_elapsed (struct timeval *origin)
+{
+ struct timeval tv;
+
+ gettimeofday (&tv, NULL);
+ return (tv.tv_sec - origin->tv_sec) * 1000 + (tv.tv_usec - origin->tv_usec) / 1000;
+}
+
DBusMessage *
dbind_send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, DBusError *error)
{
@@ -37,6 +47,7 @@ dbind_send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, DBusE
SpiReentrantCallClosure closure;
const char *unique_name = dbus_bus_get_unique_name (bus);
const char *destination = dbus_message_get_destination (message);
+ struct timeval tv;
if (unique_name && destination &&
strcmp (destination, unique_name) != 0)
@@ -51,10 +62,13 @@ dbind_send_and_allow_reentry (DBusConnection * bus, DBusMessage * message, DBusE
dbus_pending_call_set_notify (pending, set_reply, (void *) &closure, NULL);
closure.reply = NULL;
+ gettimeofday (&tv, NULL);
while (!closure.reply)
{
if (!dbus_connection_read_write_dispatch (bus, dbind_timeout))
return NULL;
+if (time_elapsed (&tv) > dbind_timeout)
+ return NULL;
}
return closure.reply;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]