Lines Matching refs:eloop
38 WPA_TRACE_REF(eloop);
49 WPA_TRACE_REF(eloop);
102 static struct eloop_data eloop; variable
119 wpa_trace_add_ref(&table->table[i], eloop, in eloop_trace_sock_add_ref()
133 wpa_trace_remove_ref(&table->table[i], eloop, in eloop_trace_sock_remove_ref()
150 os_memset(&eloop, 0, sizeof(eloop)); in eloop_init()
151 dl_list_init(&eloop.timeout); in eloop_init()
153 eloop.epollfd = epoll_create1(0); in eloop_init()
154 if (eloop.epollfd < 0) { in eloop_init()
159 eloop.readers.type = EVENT_TYPE_READ; in eloop_init()
160 eloop.writers.type = EVENT_TYPE_WRITE; in eloop_init()
161 eloop.exceptions.type = EVENT_TYPE_EXCEPTION; in eloop_init()
182 if (sock > eloop.max_sock) in eloop_sock_table_add_sock()
185 new_max_sock = eloop.max_sock; in eloop_sock_table_add_sock()
191 if (new_max_sock >= eloop.max_pollfd_map) { in eloop_sock_table_add_sock()
193 nmap = os_realloc_array(eloop.pollfds_map, new_max_sock + 50, in eloop_sock_table_add_sock()
198 eloop.max_pollfd_map = new_max_sock + 50; in eloop_sock_table_add_sock()
199 eloop.pollfds_map = nmap; in eloop_sock_table_add_sock()
202 if (eloop.count + 1 > eloop.max_poll_fds) { in eloop_sock_table_add_sock()
204 int nmax = eloop.count + 1 + 50; in eloop_sock_table_add_sock()
205 n = os_realloc_array(eloop.pollfds, nmax, in eloop_sock_table_add_sock()
210 eloop.max_poll_fds = nmax; in eloop_sock_table_add_sock()
211 eloop.pollfds = n; in eloop_sock_table_add_sock()
215 if (new_max_sock >= eloop.epoll_max_fd) { in eloop_sock_table_add_sock()
216 next = eloop.epoll_max_fd == 0 ? 16 : eloop.epoll_max_fd * 2; in eloop_sock_table_add_sock()
217 temp_table = os_realloc_array(eloop.epoll_table, next, in eloop_sock_table_add_sock()
222 eloop.epoll_max_fd = next; in eloop_sock_table_add_sock()
223 eloop.epoll_table = temp_table; in eloop_sock_table_add_sock()
226 if (eloop.count + 1 > eloop.epoll_max_event_num) { in eloop_sock_table_add_sock()
227 next = eloop.epoll_max_event_num == 0 ? 8 : in eloop_sock_table_add_sock()
228 eloop.epoll_max_event_num * 2; in eloop_sock_table_add_sock()
229 temp_events = os_realloc_array(eloop.epoll_events, next, in eloop_sock_table_add_sock()
237 eloop.epoll_max_event_num = next; in eloop_sock_table_add_sock()
238 eloop.epoll_events = temp_events; in eloop_sock_table_add_sock()
257 eloop.max_sock = new_max_sock; in eloop_sock_table_add_sock()
258 eloop.count++; in eloop_sock_table_add_sock()
283 if (epoll_ctl(eloop.epollfd, EPOLL_CTL_ADD, sock, &ev) < 0) { in eloop_sock_table_add_sock()
288 os_memcpy(&eloop.epoll_table[sock], &table->table[table->count - 1], in eloop_sock_table_add_sock()
316 eloop.count--; in eloop_sock_table_remove_sock()
322 if (epoll_ctl(eloop.epollfd, EPOLL_CTL_DEL, sock, NULL) < 0) { in eloop_sock_table_remove_sock()
327 os_memset(&eloop.epoll_table[sock], 0, sizeof(struct eloop_sock)); in eloop_sock_table_remove_sock()
521 table = &eloop.epoll_table[events[i].data.fd]; in eloop_sock_table_dispatch()
571 return &eloop.readers; in eloop_get_sock_table()
573 return &eloop.writers; in eloop_get_sock_table()
575 return &eloop.exceptions; in eloop_get_sock_table()
638 wpa_trace_add_ref(timeout, eloop, eloop_data); in eloop_register_timeout()
643 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_register_timeout()
649 dl_list_add_tail(&eloop.timeout, &timeout->list); in eloop_register_timeout()
658 wpa_trace_remove_ref(timeout, eloop, timeout->eloop_data); in eloop_remove_timeout()
670 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_cancel_timeout()
697 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_cancel_timeout_one()
718 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_is_timeout_registered()
736 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_deplete_timeout()
768 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) { in eloop_replenish_timeout()
811 if ((sig == SIGINT || sig == SIGTERM) && !eloop.pending_terminate) { in eloop_handle_signal()
814 eloop.pending_terminate = 1; in eloop_handle_signal()
820 eloop.signaled++; in eloop_handle_signal()
821 for (i = 0; i < eloop.signal_count; i++) { in eloop_handle_signal()
822 if (eloop.signals[i].sig == sig) { in eloop_handle_signal()
823 eloop.signals[i].signaled++; in eloop_handle_signal()
834 if (eloop.signaled == 0) in eloop_process_pending_signals()
836 eloop.signaled = 0; in eloop_process_pending_signals()
838 if (eloop.pending_terminate) { in eloop_process_pending_signals()
842 eloop.pending_terminate = 0; in eloop_process_pending_signals()
845 for (i = 0; i < eloop.signal_count; i++) { in eloop_process_pending_signals()
846 if (eloop.signals[i].signaled) { in eloop_process_pending_signals()
847 eloop.signals[i].signaled = 0; in eloop_process_pending_signals()
848 eloop.signals[i].handler(eloop.signals[i].sig, in eloop_process_pending_signals()
849 eloop.signals[i].user_data); in eloop_process_pending_signals()
860 tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1, in eloop_register_signal()
865 tmp[eloop.signal_count].sig = sig; in eloop_register_signal()
866 tmp[eloop.signal_count].user_data = user_data; in eloop_register_signal()
867 tmp[eloop.signal_count].handler = handler; in eloop_register_signal()
868 tmp[eloop.signal_count].signaled = 0; in eloop_register_signal()
869 eloop.signal_count++; in eloop_register_signal()
870 eloop.signals = tmp; in eloop_register_signal()
922 while (!eloop.terminate && in eloop_run()
923 (!dl_list_empty(&eloop.timeout) || eloop.readers.count > 0 || in eloop_run()
924 eloop.writers.count > 0 || eloop.exceptions.count > 0)) { in eloop_run()
926 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, in eloop_run()
945 &eloop.readers, &eloop.writers, &eloop.exceptions, in eloop_run()
946 eloop.pollfds, eloop.pollfds_map, in eloop_run()
947 eloop.max_pollfd_map); in eloop_run()
948 res = poll(eloop.pollfds, num_poll_fds, in eloop_run()
952 eloop_sock_table_set_fds(&eloop.readers, rfds); in eloop_run()
953 eloop_sock_table_set_fds(&eloop.writers, wfds); in eloop_run()
954 eloop_sock_table_set_fds(&eloop.exceptions, efds); in eloop_run()
955 res = select(eloop.max_sock + 1, rfds, wfds, efds, in eloop_run()
959 if (eloop.count == 0) { in eloop_run()
962 res = epoll_wait(eloop.epollfd, eloop.epoll_events, in eloop_run()
963 eloop.count, timeout_ms); in eloop_run()
983 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout, in eloop_run()
1002 eloop_sock_table_dispatch(&eloop.readers, &eloop.writers, in eloop_run()
1003 &eloop.exceptions, eloop.pollfds_map, in eloop_run()
1004 eloop.max_pollfd_map); in eloop_run()
1007 eloop_sock_table_dispatch(&eloop.readers, rfds); in eloop_run()
1008 eloop_sock_table_dispatch(&eloop.writers, wfds); in eloop_run()
1009 eloop_sock_table_dispatch(&eloop.exceptions, efds); in eloop_run()
1012 eloop_sock_table_dispatch(eloop.epoll_events, res); in eloop_run()
1016 eloop.terminate = 0; in eloop_run()
1029 eloop.terminate = 1; in eloop_terminate()
1039 dl_list_for_each_safe(timeout, prev, &eloop.timeout, in eloop_destroy()
1057 eloop_sock_table_destroy(&eloop.readers); in eloop_destroy()
1058 eloop_sock_table_destroy(&eloop.writers); in eloop_destroy()
1059 eloop_sock_table_destroy(&eloop.exceptions); in eloop_destroy()
1060 os_free(eloop.signals); in eloop_destroy()
1063 os_free(eloop.pollfds); in eloop_destroy()
1064 os_free(eloop.pollfds_map); in eloop_destroy()
1067 os_free(eloop.epoll_table); in eloop_destroy()
1068 os_free(eloop.epoll_events); in eloop_destroy()
1069 close(eloop.epollfd); in eloop_destroy()
1076 return eloop.terminate; in eloop_terminated()