X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Ftimeeventq.c;h=88e17792e09436f8cf43d3c7fcb2e7a1d80e3dbb;hb=5d047523c87ba11aad8c384f7ffde25b4dd746ed;hp=60d9fe0eb1ebd7a1e1264bc246aa9094eba2b26b;hpb=774b0629a3536eda0b560e092964cf94d6b742aa;p=catta diff --git a/avahi-core/timeeventq.c b/avahi-core/timeeventq.c index 60d9fe0..88e1779 100644 --- a/avahi-core/timeeventq.c +++ b/avahi-core/timeeventq.c @@ -23,8 +23,8 @@ #include #endif +#include #include "timeeventq.h" -#include "util.h" static gint compare(gconstpointer _a, gconstpointer _b) { const AvahiTimeEvent *a = _a, *b = _b; @@ -38,10 +38,21 @@ static gint compare(gconstpointer _a, gconstpointer _b) { return avahi_timeval_compare(&a->last_run, &b->last_run); } +static void source_get_timeval(GSource *source, struct timeval *tv) { + GTimeVal gtv; + + g_assert(source); + g_assert(tv); + + g_source_get_current_time(source, >v); + tv->tv_sec = gtv.tv_sec; + tv->tv_usec = gtv.tv_usec; +} + static gboolean prepare_func(GSource *source, gint *timeout) { AvahiTimeEventQueue *q = (AvahiTimeEventQueue*) source; AvahiTimeEvent *e; - GTimeVal now; + struct timeval now; g_assert(source); g_assert(timeout); @@ -54,7 +65,7 @@ static gboolean prepare_func(GSource *source, gint *timeout) { e = q->prioq->root->data; g_assert(e); - g_source_get_current_time(source, &now); + source_get_timeval(source, &now); if (avahi_timeval_compare(&now, &e->expiry) >= 0 && /* Time elapsed */ avahi_timeval_compare(&now, &e->last_run) != 0 /* Not yet run */) { @@ -74,7 +85,7 @@ static gboolean prepare_func(GSource *source, gint *timeout) { static gboolean check_func(GSource *source) { AvahiTimeEventQueue *q = (AvahiTimeEventQueue*) source; AvahiTimeEvent *e; - GTimeVal now; + struct timeval now; g_assert(source); @@ -84,7 +95,7 @@ static gboolean check_func(GSource *source) { e = q->prioq->root->data; g_assert(e); - g_source_get_current_time(source, &now); + source_get_timeval(source, &now); return avahi_timeval_compare(&now, &e->expiry) >= 0 && /* Time elapsed */ @@ -93,11 +104,11 @@ static gboolean check_func(GSource *source) { static gboolean dispatch_func(GSource *source, GSourceFunc callback, gpointer user_data) { AvahiTimeEventQueue *q = (AvahiTimeEventQueue*) source; - GTimeVal now; + struct timeval now; g_assert(source); - g_source_get_current_time(source, &now); + source_get_timeval(source, &now); while (q->prioq->root) { AvahiTimeEvent *e = q->prioq->root->data; @@ -123,10 +134,10 @@ static gboolean dispatch_func(GSource *source, GSourceFunc callback, gpointer us } static void fix_expiry_time(AvahiTimeEvent *e) { - GTimeVal now; + struct timeval now; g_assert(e); - g_source_get_current_time(&e->queue->source, &now); + source_get_timeval(&e->queue->source, &now); if (avahi_timeval_compare(&now, &e->expiry) > 0) e->expiry = now; @@ -166,7 +177,7 @@ void avahi_time_event_queue_free(AvahiTimeEventQueue *q) { g_source_unref(&q->source); } -AvahiTimeEvent* avahi_time_event_queue_add(AvahiTimeEventQueue *q, const GTimeVal *timeval, AvahiTimeEventCallback callback, gpointer userdata) { +AvahiTimeEvent* avahi_time_event_queue_add(AvahiTimeEventQueue *q, const struct timeval *timeval, AvahiTimeEventCallback callback, gpointer userdata) { AvahiTimeEvent *e; g_assert(q); @@ -199,7 +210,7 @@ void avahi_time_event_queue_remove(AvahiTimeEventQueue *q, AvahiTimeEvent *e) { g_free(e); } -void avahi_time_event_queue_update(AvahiTimeEventQueue *q, AvahiTimeEvent *e, const GTimeVal *timeval) { +void avahi_time_event_queue_update(AvahiTimeEventQueue *q, AvahiTimeEvent *e, const struct timeval *timeval) { g_assert(q); g_assert(e); g_assert(e->queue == q);