Lines Matching refs:w
133 AvahiWatch *w; in watch_new() local
143 if (!(w = avahi_new(AvahiWatch, 1))) in watch_new()
149 w->simple_poll = s; in watch_new()
150 w->dead = 0; in watch_new()
152 w->pollfd.fd = fd; in watch_new()
153 w->pollfd.events = event; in watch_new()
154 w->pollfd.revents = 0; in watch_new()
156 w->callback = callback; in watch_new()
157 w->userdata = userdata; in watch_new()
159 w->idx = -1; in watch_new()
162 AVAHI_LLIST_PREPEND(AvahiWatch, watches, s->watches, w); in watch_new()
165 return w; in watch_new()
168 static void watch_update(AvahiWatch *w, AvahiWatchEvent events) { in watch_update() argument
169 assert(w); in watch_update()
170 assert(!w->dead); in watch_update()
173 avahi_simple_poll_wakeup(w->simple_poll); in watch_update()
175 w->pollfd.events = events; in watch_update()
177 if (w->idx != -1) { in watch_update()
178 assert(w->simple_poll); in watch_update()
179 w->simple_poll->pollfds[w->idx] = w->pollfd; in watch_update()
181 w->simple_poll->rebuild_pollfds = 1; in watch_update()
184 static AvahiWatchEvent watch_get_events(AvahiWatch *w) { in watch_get_events() argument
185 assert(w); in watch_get_events()
186 assert(!w->dead); in watch_get_events()
188 if (w->idx != -1 && w->simple_poll->events_valid) in watch_get_events()
189 return w->simple_poll->pollfds[w->idx].revents; in watch_get_events()
194 static void remove_pollfd(AvahiWatch *w) { in remove_pollfd() argument
195 assert(w); in remove_pollfd()
197 if (w->idx == -1) in remove_pollfd()
200 w->simple_poll->rebuild_pollfds = 1; in remove_pollfd()
203 static void watch_free(AvahiWatch *w) { in watch_free() argument
204 assert(w); in watch_free()
206 assert(!w->dead); in watch_free()
209 avahi_simple_poll_wakeup(w->simple_poll); in watch_free()
211 remove_pollfd(w); in watch_free()
213 w->dead = 1; in watch_free()
214 w->simple_poll->n_watches --; in watch_free()
215 w->simple_poll->watch_req_cleanup = 1; in watch_free()
218 static void destroy_watch(AvahiWatch *w) { in destroy_watch() argument
219 assert(w); in destroy_watch()
221 remove_pollfd(w); in destroy_watch()
222 AVAHI_LLIST_REMOVE(AvahiWatch, watches, w->simple_poll->watches, w); in destroy_watch()
224 if (!w->dead) in destroy_watch()
225 w->simple_poll->n_watches --; in destroy_watch()
227 avahi_free(w); in destroy_watch()
231 AvahiWatch *w, *next; in cleanup_watches() local
234 for (w = s->watches; w; w = next) { in cleanup_watches()
235 next = w->watches_next; in cleanup_watches()
237 if (all || w->dead) in cleanup_watches()
238 destroy_watch(w); in cleanup_watches()
386 AvahiWatch *w; in rebuild() local
409 for (w = s->watches; w; w = w->watches_next) { in rebuild()
411 if(w->dead) in rebuild()
414 assert(w->idx < s->max_pollfds); in rebuild()
415 s->pollfds[w->idx = idx++] = w->pollfd; in rebuild()
549 AvahiWatch *w; in avahi_simple_poll_dispatch() local
576 for (w = s->watches; w; w = w->watches_next) { in avahi_simple_poll_dispatch()
578 if (w->dead) in avahi_simple_poll_dispatch()
581 assert(w->idx >= 0); in avahi_simple_poll_dispatch()
582 assert(w->idx < s->n_pollfds); in avahi_simple_poll_dispatch()
584 if (s->pollfds[w->idx].revents != 0) { in avahi_simple_poll_dispatch()
585 w->callback(w, w->pollfd.fd, s->pollfds[w->idx].revents, w->userdata); in avahi_simple_poll_dispatch()