diff options
Diffstat (limited to 'src/lib/ecore_avahi/ecore_avahi.c')
-rw-r--r-- | src/lib/ecore_avahi/ecore_avahi.c | 17 |
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) | |||
44 | { | 44 | { |
45 | return (events & AVAHI_WATCH_IN ? ECORE_FD_READ : 0) | | 45 | return (events & AVAHI_WATCH_IN ? ECORE_FD_READ : 0) | |
46 | (events & AVAHI_WATCH_OUT ? ECORE_FD_WRITE : 0) | | 46 | (events & AVAHI_WATCH_OUT ? ECORE_FD_WRITE : 0) | |
47 | (events & AVAHI_WATCH_ERR ? ECORE_FD_ERROR : 0); | 47 | ECORE_FD_ERROR; |
48 | } | 48 | } |
49 | 49 | ||
50 | static Eina_Bool | 50 | static Eina_Bool |
@@ -119,8 +119,17 @@ _ecore_avahi_watch_get_events(AvahiWatch *w) | |||
119 | static double | 119 | static double |
120 | _ecore_avahi_timeval2double(const struct timeval *tv) | 120 | _ecore_avahi_timeval2double(const struct timeval *tv) |
121 | { | 121 | { |
122 | struct timeval now; | ||
123 | double tm; | ||
124 | |||
122 | if (!tv) return 3600; | 125 | if (!tv) return 3600; |
123 | return tv->tv_sec + (double) tv->tv_usec / 1000000; | 126 | |
127 | gettimeofday(&now, NULL); | ||
128 | |||
129 | tm = tv->tv_sec - now.tv_sec + (double) (tv->tv_usec - now.tv_usec) / 1000000; | ||
130 | if (tm < 0) tm = 0.001; | ||
131 | |||
132 | return tm; | ||
124 | } | 133 | } |
125 | 134 | ||
126 | static Eina_Bool | 135 | static Eina_Bool |
@@ -144,8 +153,8 @@ _ecore_avahi_timeout_new(const AvahiPoll *api, const struct timeval *tv, | |||
144 | ea = api->userdata; | 153 | ea = api->userdata; |
145 | timeout = calloc(1, sizeof (Ecore_Avahi_Timeout)); | 154 | timeout = calloc(1, sizeof (Ecore_Avahi_Timeout)); |
146 | if (!timeout) return NULL; | 155 | if (!timeout) return NULL; |
147 | 156 | timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv), | |
148 | timeout->timer = ecore_timer_add(_ecore_avahi_timeval2double(tv), _ecore_avahi_timeout_cb, timeout); | 157 | _ecore_avahi_timeout_cb, timeout); |
149 | if (!tv) ecore_timer_freeze(timeout->timer); | 158 | if (!tv) ecore_timer_freeze(timeout->timer); |
150 | timeout->callback = callback; | 159 | timeout->callback = callback; |
151 | timeout->callback_data = userdata; | 160 | timeout->callback_data = userdata; |