aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCedric Bail <cedric.bail@free.fr>2014-02-28 19:57:44 -0300
committerCedric Bail <cedric.bail@free.fr>2014-02-28 20:01:05 -0300
commit2c615df2d2c5e95d965b301d65769bb56ec340d5 (patch)
tree1a1a7f1b59d6ad0d2e740bd9df3b34f752fd98ed /src
parentexamples/evas: Set a proper format string for fprintf (diff)
downloadefl-2c615df2d2c5e95d965b301d65769bb56ec340d5.tar.gz
ecore_avahi: @fix timeout to avoid pitfall of forever frozen timer.
@backport.
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore_avahi/ecore_avahi.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/lib/ecore_avahi/ecore_avahi.c b/src/lib/ecore_avahi/ecore_avahi.c
index 8957d0a573..6af79e4a72 100644
--- a/src/lib/ecore_avahi/ecore_avahi.c
+++ b/src/lib/ecore_avahi/ecore_avahi.c
@@ -88,7 +88,7 @@ _ecore_avahi_watch_new(const AvahiPoll *api,
static void
_ecore_avahi_watch_update(AvahiWatch *w, AvahiWatchEvent events)
{
- Ecore_Avahi_Watch *watch = (Ecore_Avahi_Watch *) w;
+ Ecore_Avahi_Watch *watch = (Ecore_Avahi_Watch *) w;
ecore_main_fd_handler_active_set(watch->handler, _ecore_avahi_events2ecore(events));
}
@@ -137,10 +137,10 @@ _ecore_avahi_timeout_cb(void *data)
{
Ecore_Avahi_Timeout *timeout = data;
- ecore_timer_freeze(timeout->timer);
timeout->callback((AvahiTimeout*) timeout, timeout->callback_data);
- return ECORE_CALLBACK_RENEW;
+ timeout->timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
}
static AvahiTimeout *
@@ -153,9 +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);
- if (!tv) ecore_timer_freeze(timeout->timer);
+ if (tv) timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv),
+ _ecore_avahi_timeout_cb, timeout);
timeout->callback = callback;
timeout->callback_data = userdata;
timeout->parent = ea;
@@ -170,16 +169,12 @@ _ecore_avahi_timeout_update(AvahiTimeout *t, const struct timeval *tv)
{
Ecore_Avahi_Timeout *timeout = (Ecore_Avahi_Timeout *) t;
+ if (timeout->timer) ecore_timer_del(timeout->timer);
+ timeout->timer = NULL;
+
if (tv)
- {
- ecore_timer_interval_set(timeout->timer, _ecore_avahi_timeval2double(tv));
- if (ecore_timer_freeze_get(timeout->timer))
- ecore_timer_thaw(timeout->timer);
- }
- else
- {
- ecore_timer_freeze(timeout->timer);
- }
+ timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv),
+ _ecore_avahi_timeout_cb, timeout);
}
static void
@@ -187,7 +182,7 @@ _ecore_avahi_timeout_free(AvahiTimeout *t)
{
Ecore_Avahi_Timeout *timeout = (Ecore_Avahi_Timeout *) t;
- ecore_timer_del(timeout->timer);
+ if (timeout->timer) ecore_timer_del(timeout->timer);
timeout->parent->timeouts = eina_list_remove(timeout->parent->timeouts, timeout);
free(timeout);
}