Lines Matching refs:eloop
47 WPA_TRACE_REF(eloop);
58 WPA_TRACE_REF(eloop);
115 static struct eloop_data eloop; variable
132 wpa_trace_add_ref(&table->table[i], eloop, in eloop_trace_sock_add_ref()
146 wpa_trace_remove_ref(&table->table[i], eloop, in eloop_trace_sock_remove_ref()
163 os_memset(&eloop, 0, sizeof(eloop)); in eloop_init()
164 dl_list_init(&eloop.timeout); in eloop_init()
166 eloop.epollfd = epoll_create1(0); in eloop_init()
167 if (eloop.epollfd < 0) { in eloop_init()
174 eloop.kqueuefd = kqueue(); in eloop_init()
175 if (eloop.kqueuefd < 0) { in eloop_init()
182 eloop.readers.type = EVENT_TYPE_READ; in eloop_init()
183 eloop.writers.type = EVENT_TYPE_WRITE; in eloop_init()
184 eloop.exceptions.type = EVENT_TYPE_EXCEPTION; in eloop_init()
216 if (epoll_ctl(eloop.epollfd, EPOLL_CTL_ADD, sock, &ev) < 0) { in eloop_sock_queue()
243 if (kevent(eloop.kqueuefd, &ke, 1, NULL, 0, NULL) == -1) { in eloop_sock_queue()
270 if (sock > eloop.max_sock) in eloop_sock_table_add_sock()
273 new_max_sock = eloop.max_sock; in eloop_sock_table_add_sock()
279 if (new_max_sock >= eloop.max_pollfd_map) { in eloop_sock_table_add_sock()
281 nmap = os_realloc_array(eloop.pollfds_map, new_max_sock + 50, in eloop_sock_table_add_sock()
286 eloop.max_pollfd_map = new_max_sock + 50; in eloop_sock_table_add_sock()
287 eloop.pollfds_map = nmap; in eloop_sock_table_add_sock()
290 if (eloop.count + 1 > eloop.max_poll_fds) { in eloop_sock_table_add_sock()
292 int nmax = eloop.count + 1 + 50; in eloop_sock_table_add_sock()
293 n = os_realloc_array(eloop.pollfds, nmax, in eloop_sock_table_add_sock()
298 eloop.max_poll_fds = nmax; in eloop_sock_table_add_sock()
299 eloop.pollfds = n; in eloop_sock_table_add_sock()
303 if (new_max_sock >= eloop.max_fd) { in eloop_sock_table_add_sock()
304 next = eloop.max_fd == 0 ? 16 : eloop.max_fd * 2; in eloop_sock_table_add_sock()
305 temp_table = os_realloc_array(eloop.fd_table, next, in eloop_sock_table_add_sock()
310 eloop.max_fd = next; in eloop_sock_table_add_sock()
311 eloop.fd_table = temp_table; in eloop_sock_table_add_sock()
316 if (eloop.count + 1 > eloop.epoll_max_event_num) { in eloop_sock_table_add_sock()
317 next = eloop.epoll_max_event_num == 0 ? 8 : in eloop_sock_table_add_sock()
318 eloop.epoll_max_event_num * 2; in eloop_sock_table_add_sock()
319 temp_events = os_realloc_array(eloop.epoll_events, next, in eloop_sock_table_add_sock()
327 eloop.epoll_max_event_num = next; in eloop_sock_table_add_sock()
328 eloop.epoll_events = temp_events; in eloop_sock_table_add_sock()
332 if (eloop.count + 1 > eloop.kqueue_nevents) { in eloop_sock_table_add_sock()
333 next = eloop.kqueue_nevents == 0 ? 8 : eloop.kqueue_nevents * 2; in eloop_sock_table_add_sock()
342 os_free(eloop.kqueue_events); in eloop_sock_table_add_sock()
343 eloop.kqueue_events = temp_events; in eloop_sock_table_add_sock()
344 eloop.kqueue_nevents = next; in eloop_sock_table_add_sock()
363 eloop.max_sock = new_max_sock; in eloop_sock_table_add_sock()
364 eloop.count++; in eloop_sock_table_add_sock()
371 os_memcpy(&eloop.fd_table[sock], &table->table[table->count - 1], in eloop_sock_table_add_sock()
402 eloop.count--; in eloop_sock_table_remove_sock()
406 if (epoll_ctl(eloop.epollfd, EPOLL_CTL_DEL, sock, NULL) < 0) { in eloop_sock_table_remove_sock()
411 os_memset(&eloop.fd_table[sock], 0, sizeof(struct eloop_sock)); in eloop_sock_table_remove_sock()
415 if (kevent(eloop.kqueuefd, &ke, 1, NULL, 0, NULL) < 0) { in eloop_sock_table_remove_sock()
420 os_memset(&eloop.fd_table[sock], 0, sizeof(struct eloop_sock)); in eloop_sock_table_remove_sock()
614 table = &eloop.fd_table[events[i].data.fd]; in eloop_sock_table_dispatch()
619 if (eloop.readers.changed || in eloop_sock_table_dispatch()
620 eloop.writers.changed || in eloop_sock_table_dispatch()
621 eloop.exceptions.changed) in eloop_sock_table_dispatch()
636 table = &eloop.fd_table[events[i].ident]; in eloop_sock_table_dispatch()
641 if (eloop.readers.changed || in eloop_sock_table_dispatch()
642 eloop.writers.changed || in eloop_sock_table_dispatch()
643 eloop.exceptions.changed) in eloop_sock_table_dispatch()
669 close(eloop.kqueuefd); in eloop_sock_requeue()
670 eloop.kqueuefd = kqueue(); in eloop_sock_requeue()
671 if (eloop.kqueuefd < 0) { in eloop_sock_requeue()
677 if (eloop_sock_table_requeue(&eloop.readers) < 0) in eloop_sock_requeue()
679 if (eloop_sock_table_requeue(&eloop.writers) < 0) in eloop_sock_requeue()
681 if (eloop_sock_table_requeue(&eloop.exceptions) < 0) in eloop_sock_requeue()
729 return &eloop.readers; in eloop_get_sock_table()
731 return &eloop.writers; in eloop_get_sock_table()
733 return &eloop.exceptions; in eloop_get_sock_table()
796 wpa_trace_add_ref(timeout, eloop, eloop_data); in eloop_register_timeout()
801 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_register_timeout()
807 dl_list_add_tail(&eloop.timeout, &timeout->list); in eloop_register_timeout()
816 wpa_trace_remove_ref(timeout, eloop, timeout->eloop_data); in eloop_remove_timeout()
828 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_cancel_timeout()
855 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_cancel_timeout_one()
876 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_is_timeout_registered()
894 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_deplete_timeout()
926 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_replenish_timeout()
969 if ((sig == SIGINT || sig == SIGTERM) && !eloop.pending_terminate) { in eloop_handle_signal()
972 eloop.pending_terminate = 1; in eloop_handle_signal()
978 eloop.signaled++; in eloop_handle_signal()
979 for (i = 0; i < eloop.signal_count; i++) { in eloop_handle_signal()
980 if (eloop.signals[i].sig == sig) { in eloop_handle_signal()
981 eloop.signals[i].signaled++; in eloop_handle_signal()
992 if (eloop.signaled == 0) in eloop_process_pending_signals()
994 eloop.signaled = 0; in eloop_process_pending_signals()
996 if (eloop.pending_terminate) { in eloop_process_pending_signals()
1000 eloop.pending_terminate = 0; in eloop_process_pending_signals()
1003 for (i = 0; i < eloop.signal_count; i++) { in eloop_process_pending_signals()
1004 if (eloop.signals[i].signaled) { in eloop_process_pending_signals()
1005 eloop.signals[i].signaled = 0; in eloop_process_pending_signals()
1006 eloop.signals[i].handler(eloop.signals[i].sig, in eloop_process_pending_signals()
1007 eloop.signals[i].user_data); in eloop_process_pending_signals()
1018 tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1, in eloop_register_signal()
1023 tmp[eloop.signal_count].sig = sig; in eloop_register_signal()
1024 tmp[eloop.signal_count].user_data = user_data; in eloop_register_signal()
1025 tmp[eloop.signal_count].handler = handler; in eloop_register_signal()
1026 tmp[eloop.signal_count].signaled = 0; in eloop_register_signal()
1027 eloop.signal_count++; in eloop_register_signal()
1028 eloop.signals = tmp; in eloop_register_signal()
1083 while (!eloop.terminate && in eloop_run()
1084 (!dl_list_empty(&eloop.timeout) || eloop.readers.count > 0 || in eloop_run()
1085 eloop.writers.count > 0 || eloop.exceptions.count > 0)) { in eloop_run()
1088 if (eloop.pending_terminate) { in eloop_run()
1097 if (eloop.terminate) in eloop_run()
1101 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, in eloop_run()
1124 &eloop.readers, &eloop.writers, &eloop.exceptions, in eloop_run()
1125 eloop.pollfds, eloop.pollfds_map, in eloop_run()
1126 eloop.max_pollfd_map); in eloop_run()
1127 res = poll(eloop.pollfds, num_poll_fds, in eloop_run()
1131 eloop_sock_table_set_fds(&eloop.readers, rfds); in eloop_run()
1132 eloop_sock_table_set_fds(&eloop.writers, wfds); in eloop_run()
1133 eloop_sock_table_set_fds(&eloop.exceptions, efds); in eloop_run()
1134 res = select(eloop.max_sock + 1, rfds, wfds, efds, in eloop_run()
1138 if (eloop.count == 0) { in eloop_run()
1141 res = epoll_wait(eloop.epollfd, eloop.epoll_events, in eloop_run()
1142 eloop.count, timeout_ms); in eloop_run()
1146 if (eloop.count == 0) { in eloop_run()
1149 res = kevent(eloop.kqueuefd, NULL, 0, in eloop_run()
1150 eloop.kqueue_events, eloop.kqueue_nevents, in eloop_run()
1173 eloop.readers.changed = 0; in eloop_run()
1174 eloop.writers.changed = 0; in eloop_run()
1175 eloop.exceptions.changed = 0; in eloop_run()
1181 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, in eloop_run()
1199 if (eloop.readers.changed || in eloop_run()
1200 eloop.writers.changed || in eloop_run()
1201 eloop.exceptions.changed) { in eloop_run()
1213 eloop_sock_table_dispatch(&eloop.readers, &eloop.writers, in eloop_run()
1214 &eloop.exceptions, eloop.pollfds_map, in eloop_run()
1215 eloop.max_pollfd_map); in eloop_run()
1218 eloop_sock_table_dispatch(&eloop.readers, rfds); in eloop_run()
1219 eloop_sock_table_dispatch(&eloop.writers, wfds); in eloop_run()
1220 eloop_sock_table_dispatch(&eloop.exceptions, efds); in eloop_run()
1223 eloop_sock_table_dispatch(eloop.epoll_events, res); in eloop_run()
1226 eloop_sock_table_dispatch(eloop.kqueue_events, res); in eloop_run()
1230 eloop.terminate = 0; in eloop_run()
1243 eloop.terminate = 1; in eloop_terminate()
1253 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_destroy()
1271 eloop_sock_table_destroy(&eloop.readers); in eloop_destroy()
1272 eloop_sock_table_destroy(&eloop.writers); in eloop_destroy()
1273 eloop_sock_table_destroy(&eloop.exceptions); in eloop_destroy()
1274 os_free(eloop.signals); in eloop_destroy()
1277 os_free(eloop.pollfds); in eloop_destroy()
1278 os_free(eloop.pollfds_map); in eloop_destroy()
1281 os_free(eloop.fd_table); in eloop_destroy()
1284 os_free(eloop.epoll_events); in eloop_destroy()
1285 close(eloop.epollfd); in eloop_destroy()
1288 os_free(eloop.kqueue_events); in eloop_destroy()
1289 close(eloop.kqueuefd); in eloop_destroy()
1296 return eloop.terminate || eloop.pending_terminate; in eloop_terminated()