Lines Matching refs:eloop

47 	WPA_TRACE_REF(eloop);
58 WPA_TRACE_REF(eloop);
115 static struct eloop_data eloop; variable
133 wpa_trace_add_ref(&table->table[i], eloop, in eloop_trace_sock_add_ref()
148 wpa_trace_remove_ref(&table->table[i], eloop, in eloop_trace_sock_remove_ref()
165 os_memset(&eloop, 0, sizeof(eloop)); in eloop_init()
166 dl_list_init(&eloop.timeout); in eloop_init()
168 eloop.epollfd = epoll_create1(0); in eloop_init()
169 if (eloop.epollfd < 0) { in eloop_init()
176 eloop.kqueuefd = kqueue(); in eloop_init()
177 if (eloop.kqueuefd < 0) { in eloop_init()
184 eloop.readers.type = EVENT_TYPE_READ; in eloop_init()
185 eloop.writers.type = EVENT_TYPE_WRITE; in eloop_init()
186 eloop.exceptions.type = EVENT_TYPE_EXCEPTION; in eloop_init()
218 if (epoll_ctl(eloop.epollfd, EPOLL_CTL_ADD, sock, &ev) < 0) { in eloop_sock_queue()
248 if (kevent(eloop.kqueuefd, &ke, 1, NULL, 0, NULL) == -1) { in eloop_sock_queue()
276 if (sock > eloop.max_sock) in eloop_sock_table_add_sock()
279 new_max_sock = eloop.max_sock; in eloop_sock_table_add_sock()
285 if ((size_t) new_max_sock >= eloop.max_pollfd_map) { in eloop_sock_table_add_sock()
287 nmap = os_realloc_array(eloop.pollfds_map, new_max_sock + 50, in eloop_sock_table_add_sock()
292 eloop.max_pollfd_map = new_max_sock + 50; in eloop_sock_table_add_sock()
293 eloop.pollfds_map = nmap; in eloop_sock_table_add_sock()
296 if (eloop.count + 1 > eloop.max_poll_fds) { in eloop_sock_table_add_sock()
298 size_t nmax = eloop.count + 1 + 50; in eloop_sock_table_add_sock()
300 n = os_realloc_array(eloop.pollfds, nmax, in eloop_sock_table_add_sock()
305 eloop.max_poll_fds = nmax; in eloop_sock_table_add_sock()
306 eloop.pollfds = n; in eloop_sock_table_add_sock()
310 if (new_max_sock >= eloop.max_fd) { in eloop_sock_table_add_sock()
312 temp_table = os_realloc_array(eloop.fd_table, next, in eloop_sock_table_add_sock()
317 eloop.max_fd = next; in eloop_sock_table_add_sock()
318 eloop.fd_table = temp_table; in eloop_sock_table_add_sock()
323 if (eloop.count + 1 > eloop.epoll_max_event_num) { in eloop_sock_table_add_sock()
324 next = eloop.epoll_max_event_num == 0 ? 8 : in eloop_sock_table_add_sock()
325 eloop.epoll_max_event_num * 2; in eloop_sock_table_add_sock()
326 temp_events = os_realloc_array(eloop.epoll_events, next, in eloop_sock_table_add_sock()
334 eloop.epoll_max_event_num = next; in eloop_sock_table_add_sock()
335 eloop.epoll_events = temp_events; in eloop_sock_table_add_sock()
339 if (eloop.count + 1 > eloop.kqueue_nevents) { in eloop_sock_table_add_sock()
340 next = eloop.kqueue_nevents == 0 ? 8 : eloop.kqueue_nevents * 2; in eloop_sock_table_add_sock()
349 os_free(eloop.kqueue_events); in eloop_sock_table_add_sock()
350 eloop.kqueue_events = temp_events; in eloop_sock_table_add_sock()
351 eloop.kqueue_nevents = next; in eloop_sock_table_add_sock()
370 eloop.max_sock = new_max_sock; in eloop_sock_table_add_sock()
371 eloop.count++; in eloop_sock_table_add_sock()
378 os_memcpy(&eloop.fd_table[sock], &table->table[table->count - 1], in eloop_sock_table_add_sock()
409 eloop.count--; in eloop_sock_table_remove_sock()
413 if (epoll_ctl(eloop.epollfd, EPOLL_CTL_DEL, sock, NULL) < 0) { in eloop_sock_table_remove_sock()
418 os_memset(&eloop.fd_table[sock], 0, sizeof(struct eloop_sock)); in eloop_sock_table_remove_sock()
423 if (kevent(eloop.kqueuefd, &ke, 1, NULL, 0, NULL) < 0) { in eloop_sock_table_remove_sock()
428 os_memset(&eloop.fd_table[sock], 0, sizeof(struct eloop_sock)); in eloop_sock_table_remove_sock()
622 table = &eloop.fd_table[events[i].data.fd]; in eloop_sock_table_dispatch()
627 if (eloop.readers.changed || in eloop_sock_table_dispatch()
628 eloop.writers.changed || in eloop_sock_table_dispatch()
629 eloop.exceptions.changed) in eloop_sock_table_dispatch()
644 table = &eloop.fd_table[events[i].ident]; in eloop_sock_table_dispatch()
649 if (eloop.readers.changed || in eloop_sock_table_dispatch()
650 eloop.writers.changed || in eloop_sock_table_dispatch()
651 eloop.exceptions.changed) in eloop_sock_table_dispatch()
678 close(eloop.kqueuefd); in eloop_sock_requeue()
679 eloop.kqueuefd = kqueue(); in eloop_sock_requeue()
680 if (eloop.kqueuefd < 0) { in eloop_sock_requeue()
686 if (eloop_sock_table_requeue(&eloop.readers) < 0) in eloop_sock_requeue()
688 if (eloop_sock_table_requeue(&eloop.writers) < 0) in eloop_sock_requeue()
690 if (eloop_sock_table_requeue(&eloop.exceptions) < 0) in eloop_sock_requeue()
739 return &eloop.readers; in eloop_get_sock_table()
741 return &eloop.writers; in eloop_get_sock_table()
743 return &eloop.exceptions; in eloop_get_sock_table()
806 wpa_trace_add_ref(timeout, eloop, eloop_data); in eloop_register_timeout()
811 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_register_timeout()
817 dl_list_add_tail(&eloop.timeout, &timeout->list); in eloop_register_timeout()
826 wpa_trace_remove_ref(timeout, eloop, timeout->eloop_data); in eloop_remove_timeout()
838 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_cancel_timeout()
865 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_cancel_timeout_one()
886 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_is_timeout_registered()
904 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_deplete_timeout()
936 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_replenish_timeout()
979 if ((sig == SIGINT || sig == SIGTERM) && !eloop.pending_terminate) { in eloop_handle_signal()
982 eloop.pending_terminate = 1; in eloop_handle_signal()
988 eloop.signaled++; in eloop_handle_signal()
989 for (i = 0; i < eloop.signal_count; i++) { in eloop_handle_signal()
990 if (eloop.signals[i].sig == sig) { in eloop_handle_signal()
991 eloop.signals[i].signaled++; in eloop_handle_signal()
1002 if (eloop.signaled == 0) in eloop_process_pending_signals()
1004 eloop.signaled = 0; in eloop_process_pending_signals()
1006 if (eloop.pending_terminate) { in eloop_process_pending_signals()
1010 eloop.pending_terminate = 0; in eloop_process_pending_signals()
1013 for (i = 0; i < eloop.signal_count; i++) { in eloop_process_pending_signals()
1014 if (eloop.signals[i].signaled) { in eloop_process_pending_signals()
1015 eloop.signals[i].signaled = 0; in eloop_process_pending_signals()
1016 eloop.signals[i].handler(eloop.signals[i].sig, in eloop_process_pending_signals()
1017 eloop.signals[i].user_data); in eloop_process_pending_signals()
1028 tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1, in eloop_register_signal()
1033 tmp[eloop.signal_count].sig = sig; in eloop_register_signal()
1034 tmp[eloop.signal_count].user_data = user_data; in eloop_register_signal()
1035 tmp[eloop.signal_count].handler = handler; in eloop_register_signal()
1036 tmp[eloop.signal_count].signaled = 0; in eloop_register_signal()
1037 eloop.signal_count++; in eloop_register_signal()
1038 eloop.signals = tmp; in eloop_register_signal()
1093 while (!eloop.terminate && in eloop_run()
1094 (!dl_list_empty(&eloop.timeout) || eloop.readers.count > 0 || in eloop_run()
1095 eloop.writers.count > 0 || eloop.exceptions.count > 0)) { in eloop_run()
1098 if (eloop.pending_terminate) { in eloop_run()
1107 if (eloop.terminate) in eloop_run()
1111 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, in eloop_run()
1134 &eloop.readers, &eloop.writers, &eloop.exceptions, in eloop_run()
1135 eloop.pollfds, eloop.pollfds_map, in eloop_run()
1136 eloop.max_pollfd_map); in eloop_run()
1137 res = poll(eloop.pollfds, num_poll_fds, in eloop_run()
1141 eloop_sock_table_set_fds(&eloop.readers, rfds); in eloop_run()
1142 eloop_sock_table_set_fds(&eloop.writers, wfds); in eloop_run()
1143 eloop_sock_table_set_fds(&eloop.exceptions, efds); in eloop_run()
1144 res = select(eloop.max_sock + 1, rfds, wfds, efds, in eloop_run()
1148 if (eloop.count == 0) { in eloop_run()
1151 res = epoll_wait(eloop.epollfd, eloop.epoll_events, in eloop_run()
1152 eloop.count, timeout_ms); in eloop_run()
1156 if (eloop.count == 0) { in eloop_run()
1159 res = kevent(eloop.kqueuefd, NULL, 0, in eloop_run()
1160 eloop.kqueue_events, eloop.kqueue_nevents, in eloop_run()
1183 eloop.readers.changed = 0; in eloop_run()
1184 eloop.writers.changed = 0; in eloop_run()
1185 eloop.exceptions.changed = 0; in eloop_run()
1191 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, in eloop_run()
1209 if (eloop.readers.changed || in eloop_run()
1210 eloop.writers.changed || in eloop_run()
1211 eloop.exceptions.changed) { in eloop_run()
1223 eloop_sock_table_dispatch(&eloop.readers, &eloop.writers, in eloop_run()
1224 &eloop.exceptions, eloop.pollfds_map, in eloop_run()
1225 eloop.max_pollfd_map); in eloop_run()
1228 eloop_sock_table_dispatch(&eloop.readers, rfds); in eloop_run()
1229 eloop_sock_table_dispatch(&eloop.writers, wfds); in eloop_run()
1230 eloop_sock_table_dispatch(&eloop.exceptions, efds); in eloop_run()
1233 eloop_sock_table_dispatch(eloop.epoll_events, res); in eloop_run()
1236 eloop_sock_table_dispatch(eloop.kqueue_events, res); in eloop_run()
1240 eloop.terminate = 0; in eloop_run()
1253 eloop.terminate = 1; in eloop_terminate()
1263 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_destroy()
1281 eloop_sock_table_destroy(&eloop.readers); in eloop_destroy()
1282 eloop_sock_table_destroy(&eloop.writers); in eloop_destroy()
1283 eloop_sock_table_destroy(&eloop.exceptions); in eloop_destroy()
1284 os_free(eloop.signals); in eloop_destroy()
1287 os_free(eloop.pollfds); in eloop_destroy()
1288 os_free(eloop.pollfds_map); in eloop_destroy()
1291 os_free(eloop.fd_table); in eloop_destroy()
1294 os_free(eloop.epoll_events); in eloop_destroy()
1295 close(eloop.epollfd); in eloop_destroy()
1298 os_free(eloop.kqueue_events); in eloop_destroy()
1299 close(eloop.kqueuefd); in eloop_destroy()
1306 return eloop.terminate || eloop.pending_terminate; in eloop_terminated()