summaryrefslogtreecommitdiff
path: root/src/lib/ecore_avahi
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 19:57:44 -0300
commit7d3e7ad748b905b2bdbf6c0cf16478e3cff78376 (patch)
treeccb3420b410851c8a6e7010c125df7b07c3dd02b /src/lib/ecore_avahi
parentc08c0b05a3c5282a7b120089ff9fe45020ec3391 (diff)
ecore_avahi: @fix timeout to avoid pitfall of forever frozen timer.
@backport.
Diffstat (limited to 'src/lib/ecore_avahi')
-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 8957d0a..6af79e4 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,
88static void 88static void
89_ecore_avahi_watch_update(AvahiWatch *w, AvahiWatchEvent events) 89_ecore_avahi_watch_update(AvahiWatch *w, AvahiWatchEvent events)
90{ 90{
91 Ecore_Avahi_Watch *watch = (Ecore_Avahi_Watch *) w; 91 Ecore_Avahi_Watch *watch = (Ecore_Avahi_Watch *) w;
92 92
93 ecore_main_fd_handler_active_set(watch->handler, _ecore_avahi_events2ecore(events)); 93 ecore_main_fd_handler_active_set(watch->handler, _ecore_avahi_events2ecore(events));
94} 94}
@@ -137,10 +137,10 @@ _ecore_avahi_timeout_cb(void *data)
137{ 137{
138 Ecore_Avahi_Timeout *timeout = data; 138 Ecore_Avahi_Timeout *timeout = data;
139 139
140 ecore_timer_freeze(timeout->timer);
141 timeout->callback((AvahiTimeout*) timeout, timeout->callback_data); 140 timeout->callback((AvahiTimeout*) timeout, timeout->callback_data);
142 141
143 return ECORE_CALLBACK_RENEW; 142 timeout->timer = NULL;
143 return ECORE_CALLBACK_CANCEL;
144} 144}
145 145
146static AvahiTimeout * 146static AvahiTimeout *
@@ -153,9 +153,8 @@ _ecore_avahi_timeout_new(const AvahiPoll *api, const struct timeval *tv,
153 ea = api->userdata; 153 ea = api->userdata;
154 timeout = calloc(1, sizeof (Ecore_Avahi_Timeout)); 154 timeout = calloc(1, sizeof (Ecore_Avahi_Timeout));
155 if (!timeout) return NULL; 155 if (!timeout) return NULL;
156 timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv), 156 if (tv) timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv),
157 _ecore_avahi_timeout_cb, timeout); 157 _ecore_avahi_timeout_cb, timeout);
158 if (!tv) ecore_timer_freeze(timeout->timer);
159 timeout->callback = callback; 158 timeout->callback = callback;
160 timeout->callback_data = userdata; 159 timeout->callback_data = userdata;
161 timeout->parent = ea; 160 timeout->parent = ea;
@@ -170,16 +169,12 @@ _ecore_avahi_timeout_update(AvahiTimeout *t, const struct timeval *tv)
170{ 169{
171 Ecore_Avahi_Timeout *timeout = (Ecore_Avahi_Timeout *) t; 170 Ecore_Avahi_Timeout *timeout = (Ecore_Avahi_Timeout *) t;
172 171
172 if (timeout->timer) ecore_timer_del(timeout->timer);
173 timeout->timer = NULL;
174
173 if (tv) 175 if (tv)
174 { 176 timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv),
175 ecore_timer_interval_set(timeout->timer, _ecore_avahi_timeval2double(tv)); 177 _ecore_avahi_timeout_cb, timeout);
176 if (ecore_timer_freeze_get(timeout->timer))
177 ecore_timer_thaw(timeout->timer);
178 }
179 else
180 {
181 ecore_timer_freeze(timeout->timer);
182 }
183} 178}
184 179
185static void 180static void
@@ -187,7 +182,7 @@ _ecore_avahi_timeout_free(AvahiTimeout *t)
187{ 182{
188 Ecore_Avahi_Timeout *timeout = (Ecore_Avahi_Timeout *) t; 183 Ecore_Avahi_Timeout *timeout = (Ecore_Avahi_Timeout *) t;
189 184
190 ecore_timer_del(timeout->timer); 185 if (timeout->timer) ecore_timer_del(timeout->timer);
191 timeout->parent->timeouts = eina_list_remove(timeout->parent->timeouts, timeout); 186 timeout->parent->timeouts = eina_list_remove(timeout->parent->timeouts, timeout);
192 free(timeout); 187 free(timeout);
193} 188}