summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-08-05 21:36:31 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-08-05 21:36:31 +0000
commit3c6404cd942f3b69968a390fae2a57dd2980e21a (patch)
treeaebb91523397fc914c0479971d1ad6744138f535 /common
parent70bbff923c930053ab15601023bdc12ba0258077 (diff)
fixed message reply timeout
Diffstat (limited to 'common')
-rw-r--r--common/glib-ectomy.c16
-rw-r--r--common/glib-ectomy.h7
2 files changed, 13 insertions, 10 deletions
diff --git a/common/glib-ectomy.c b/common/glib-ectomy.c
index aa1007ee..fb737642 100644
--- a/common/glib-ectomy.c
+++ b/common/glib-ectomy.c
@@ -233,7 +233,16 @@ static void timeout_handlers_prepare(GMainContext *context)
static int timeout_cmp(const void *t1, const void *t2)
{
- return t1-t2;
+ const struct timeout *tout1 = t1;
+ const struct timeout *tout2 = t2;
+
+ if (!tout2)
+ return -1;
+
+ if (tout1 != tout2)
+ return -1;
+
+ return tout1->id - tout2->id;
}
static void timeout_handlers_check(GMainContext *context)
@@ -248,9 +257,7 @@ static void timeout_handlers_check(GMainContext *context)
t = l->data;
l = l->next;
- if ((tv.tv_sec < t->expiration.tv_sec) ||
- (tv.tv_sec == t->expiration.tv_sec &&
- tv.tv_usec < t->expiration.tv_usec))
+ if (timercmp(&tv, &t->expiration, <))
continue;
if (t->function(t->data)) {
@@ -372,6 +379,7 @@ guint g_timeout_add(guint interval, GSourceFunc function, gpointer data)
if (!t)
return 0;
+ memset(t, 0, sizeof(*t));
t->interval = interval;
t->function = function;
t->data = data;
diff --git a/common/glib-ectomy.h b/common/glib-ectomy.h
index 333687b1..f52a9ce2 100644
--- a/common/glib-ectomy.h
+++ b/common/glib-ectomy.h
@@ -36,15 +36,10 @@ typedef struct _GIOChannel {
typedef gboolean (*GSourceFunc) (gpointer data);
-typedef struct {
- glong tv_sec;
- glong tv_usec;
-} time_val_t;
-
struct timeout {
guint id;
guint interval;
- time_val_t expiration;
+ struct timeval expiration;
gpointer data;
GSourceFunc function;
};