aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2014-02-27 20:07:22 -0300
committerCedric Bail <cedric.bail@free.fr>2014-02-27 20:09:52 -0300
commit5f236092c53192b4695a8c0175a22dfe3b5cdf8d (patch)
tree1892a9140ebc7ba3047a669a756a01f1ace37b1c /src
parentecore: @fix race condition when using ecore_main_loop_thread_safe_call_sync. (diff)
downloadefl-5f236092c53192b4695a8c0175a22dfe3b5cdf8d.tar.gz
ecore_avahi: fix timeout to be relative from now.
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_avahi/ecore_avahi.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/lib/ecore_avahi/ecore_avahi.c b/src/lib/ecore_avahi/ecore_avahi.c
index 93c5301bdb..8957d0a573 100644
--- a/src/lib/ecore_avahi/ecore_avahi.c
+++ b/src/lib/ecore_avahi/ecore_avahi.c
@@ -44,7 +44,7 @@ _ecore_avahi_events2ecore(AvahiWatchEvent events)
{
return (events & AVAHI_WATCH_IN ? ECORE_FD_READ : 0) |
(events & AVAHI_WATCH_OUT ? ECORE_FD_WRITE : 0) |
- (events & AVAHI_WATCH_ERR ? ECORE_FD_ERROR : 0);
+ ECORE_FD_ERROR;
}
static Eina_Bool
@@ -119,8 +119,17 @@ _ecore_avahi_watch_get_events(AvahiWatch *w)
static double
_ecore_avahi_timeval2double(const struct timeval *tv)
{
+ struct timeval now;
+ double tm;
+
if (!tv) return 3600;
- return tv->tv_sec + (double) tv->tv_usec / 1000000;
+
+ gettimeofday(&now, NULL);
+
+ tm = tv->tv_sec - now.tv_sec + (double) (tv->tv_usec - now.tv_usec) / 1000000;
+ if (tm < 0) tm = 0.001;
+
+ return tm;
}
static Eina_Bool
@@ -144,8 +153,8 @@ _ecore_avahi_timeout_new(const AvahiPoll *api, const struct timeval *tv,
ea = api->userdata;
timeout = calloc(1, sizeof (Ecore_Avahi_Timeout));
if (!timeout) return NULL;
-
- timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv), _ecore_avahi_timeout_cb, timeout);
+ timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv),
+ _ecore_avahi_timeout_cb, timeout);
if (!tv) ecore_timer_freeze(timeout->timer);
timeout->callback = callback;
timeout->callback_data = userdata;