Home | History | Annotate | Download | only in utils

Lines Matching refs:eloop

14 #include "eloop.h"
72 static struct eloop_data eloop;
77 os_memset(&eloop, 0, sizeof(eloop));
78 dl_list_init(&eloop.timeout);
79 eloop.num_handles = 1;
80 eloop.handles = os_malloc(eloop.num_handles *
81 sizeof(eloop.handles[0]));
82 if (eloop.handles == NULL)
85 eloop.term_event = CreateEvent(NULL, FALSE, FALSE, NULL);
86 if (eloop.term_event == NULL) {
89 os_free(eloop.handles);
101 if (eloop.num_handles > eloop.reader_count + eloop.event_count + 8)
103 n = os_realloc_array(eloop.handles, eloop.num_handles * 2,
104 sizeof(eloop.handles[0]));
107 eloop.handles = n;
108 eloop.num_handles *= 2;
133 tmp = os_realloc_array(eloop.readers, eloop.reader_count + 1,
141 tmp[eloop.reader_count].sock = sock;
142 tmp[eloop.reader_count].eloop_data = eloop_data;
143 tmp[eloop.reader_count].user_data = user_data;
144 tmp[eloop.reader_count].handler = handler;
145 tmp[eloop.reader_count].event = event;
146 eloop.reader_count++;
147 eloop.readers = tmp;
148 if (sock > eloop.max_sock)
149 eloop.max_sock = sock;
150 eloop.reader_table_changed = 1;
160 if (eloop.readers == NULL || eloop.reader_count == 0)
163 for (i = 0; i < eloop.reader_count; i++) {
164 if (eloop.readers[i].sock == sock)
167 if (i == eloop.reader_count)
170 WSAEventSelect(eloop.readers[i].sock, eloop.readers[i].event, 0);
171 WSACloseEvent(eloop.readers[i].event);
173 if (i != eloop.reader_count - 1) {
174 os_memmove(&eloop.readers[i], &eloop.readers[i + 1],
175 (eloop.reader_count - i - 1) *
178 eloop.reader_count--;
179 eloop.reader_table_changed = 1;
196 tmp = os_realloc_array(eloop.events, eloop.event_count + 1,
201 tmp[eloop.event_count].eloop_data = eloop_data;
202 tmp[eloop.event_count].user_data = user_data;
203 tmp[eloop.event_count].handler = handler;
204 tmp[eloop.event_count].event = h;
205 eloop.event_count++;
206 eloop.events = tmp;
217 if (eloop.events == NULL || eloop.event_count == 0 ||
221 for (i = 0; i < eloop.event_count; i++) {
222 if (eloop.events[i].event == h)
225 if (i == eloop.event_count)
228 if (i != eloop.event_count - 1) {
229 os_memmove(&eloop.events[i], &eloop.events[i + 1],
230 (eloop.event_count - i - 1) *
233 eloop.event_count--;
258 wpa_printf(MSG_DEBUG, "ELOOP: Too long timeout (secs=%u) to "
273 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
279 dl_list_add_tail(&eloop.timeout, &timeout->list);
298 dl_list_for_each_safe(timeout, prev, &eloop.timeout,
325 dl_list_for_each_safe(timeout, prev, &eloop.timeout,
346 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
364 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
396 dl_list_for_each(tmp, &eloop.timeout, struct eloop_timeout, list) {
427 eloop.signaled++;
428 for (i = 0; i < eloop.signal_count; i++) {
429 if (eloop.signals[i].sig == sig) {
430 eloop.signals[i].signaled++;
442 if (eloop.signaled == 0)
444 eloop.signaled = 0;
446 if (eloop.pending_terminate) {
447 eloop.pending_terminate = 0;
450 for (i = 0; i < eloop.signal_count; i++) {
451 if (eloop.signals[i].signaled) {
452 eloop.signals[i].signaled = 0;
453 eloop.signals[i].handler(eloop.signals[i].sig,
454 eloop.signals[i].user_data);
458 if (eloop.term_signal.signaled) {
459 eloop.term_signal.signaled = 0;
460 eloop.term_signal.handler(eloop.term_signal.sig,
461 eloop.term_signal.user_data);
471 tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1,
476 tmp[eloop.signal_count].sig = sig;
477 tmp[eloop.signal_count].user_data = user_data;
478 tmp[eloop.signal_count].handler = handler;
479 tmp[eloop.signal_count].signaled = 0;
480 eloop.signal_count++;
481 eloop.signals = tmp;
495 eloop.signaled++;
496 eloop.term_signal.signaled++;
497 SetEvent(eloop.term_event);
518 eloop.term_signal.handler = handler;
519 eloop.term_signal.user_data = user_data;
539 while (!eloop.terminate &&
540 (!dl_list_empty(&eloop.timeout) || eloop.reader_count > 0 ||
541 eloop.event_count > 0)) {
544 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
553 for (i = 0; i < eloop.event_count; i++)
554 eloop.handles[count++] = eloop.events[i].event;
556 for (i = 0; i < eloop.reader_count; i++)
557 eloop.handles[count++] = eloop.readers[i].event;
559 if (eloop.term_event)
560 eloop.handles[count++] = eloop.term_event;
574 ret = WaitForMultipleObjects(count, eloop.handles, FALSE,
577 ret = WaitForMultipleObjectsEx(count, eloop.handles, FALSE,
585 timeout = dl_list_first(&eloop.timeout, struct eloop_timeout,
616 ret < WAIT_OBJECT_0 + eloop.event_count) {
617 eloop.events[ret].handler(
618 eloop.events[ret].eloop_data,
619 eloop.events[ret].user_data);
620 ret = WaitForMultipleObjects(eloop.event_count,
621 eloop.handles, FALSE, 0);
624 eloop.reader_table_changed = 0;
625 for (i = 0; i < eloop.reader_count; i++) {
627 if (WSAEnumNetworkEvents(eloop.readers[i].sock,
628 eloop.readers[i].event,
631 eloop.readers[i].handler(
632 eloop.readers[i].sock,
633 eloop.readers[i].eloop_data,
634 eloop.readers[i].user_data);
635 if (eloop.reader_table_changed)
645 eloop.terminate = 1;
646 SetEvent(eloop.term_event);
654 dl_list_for_each_safe(timeout, prev, &eloop.timeout,
658 os_free(eloop.readers);
659 os_free(eloop.signals);
660 if (eloop.term_event)
661 CloseHandle(eloop.term_event);
662 os_free(eloop.handles);
663 eloop.handles = NULL;
664 os_free(eloop.events);
665 eloop.events = NULL;
671 return eloop.terminate;