Lines Matching refs:table
63 struct eloop_sock *table; member
113 static void eloop_trace_sock_add_ref(struct eloop_sock_table *table) in eloop_trace_sock_add_ref() argument
116 if (table == NULL || table->table == NULL) in eloop_trace_sock_add_ref()
118 for (i = 0; i < table->count; i++) { in eloop_trace_sock_add_ref()
119 wpa_trace_add_ref(&table->table[i], eloop, in eloop_trace_sock_add_ref()
120 table->table[i].eloop_data); in eloop_trace_sock_add_ref()
121 wpa_trace_add_ref(&table->table[i], user, in eloop_trace_sock_add_ref()
122 table->table[i].user_data); in eloop_trace_sock_add_ref()
127 static void eloop_trace_sock_remove_ref(struct eloop_sock_table *table) in eloop_trace_sock_remove_ref() argument
130 if (table == NULL || table->table == NULL) in eloop_trace_sock_remove_ref()
132 for (i = 0; i < table->count; i++) { in eloop_trace_sock_remove_ref()
133 wpa_trace_remove_ref(&table->table[i], eloop, in eloop_trace_sock_remove_ref()
134 table->table[i].eloop_data); in eloop_trace_sock_remove_ref()
135 wpa_trace_remove_ref(&table->table[i], user, in eloop_trace_sock_remove_ref()
136 table->table[i].user_data); in eloop_trace_sock_remove_ref()
142 #define eloop_trace_sock_add_ref(table) do { } while (0) argument
143 #define eloop_trace_sock_remove_ref(table) do { } while (0) argument
170 static int eloop_sock_table_add_sock(struct eloop_sock_table *table, in eloop_sock_table_add_sock() argument
187 if (table == NULL) in eloop_sock_table_add_sock()
242 eloop_trace_sock_remove_ref(table); in eloop_sock_table_add_sock()
243 tmp = os_realloc_array(table->table, table->count + 1, in eloop_sock_table_add_sock()
246 eloop_trace_sock_add_ref(table); in eloop_sock_table_add_sock()
250 tmp[table->count].sock = sock; in eloop_sock_table_add_sock()
251 tmp[table->count].eloop_data = eloop_data; in eloop_sock_table_add_sock()
252 tmp[table->count].user_data = user_data; in eloop_sock_table_add_sock()
253 tmp[table->count].handler = handler; in eloop_sock_table_add_sock()
254 wpa_trace_record(&tmp[table->count]); in eloop_sock_table_add_sock()
255 table->count++; in eloop_sock_table_add_sock()
256 table->table = tmp; in eloop_sock_table_add_sock()
260 table->changed = 1; in eloop_sock_table_add_sock()
262 eloop_trace_sock_add_ref(table); in eloop_sock_table_add_sock()
266 switch (table->type) { in eloop_sock_table_add_sock()
288 os_memcpy(&eloop.epoll_table[sock], &table->table[table->count - 1], in eloop_sock_table_add_sock()
295 static void eloop_sock_table_remove_sock(struct eloop_sock_table *table, in eloop_sock_table_remove_sock() argument
300 if (table == NULL || table->table == NULL || table->count == 0) in eloop_sock_table_remove_sock()
303 for (i = 0; i < table->count; i++) { in eloop_sock_table_remove_sock()
304 if (table->table[i].sock == sock) in eloop_sock_table_remove_sock()
307 if (i == table->count) in eloop_sock_table_remove_sock()
309 eloop_trace_sock_remove_ref(table); in eloop_sock_table_remove_sock()
310 if (i != table->count - 1) { in eloop_sock_table_remove_sock()
311 os_memmove(&table->table[i], &table->table[i + 1], in eloop_sock_table_remove_sock()
312 (table->count - i - 1) * in eloop_sock_table_remove_sock()
315 table->count--; in eloop_sock_table_remove_sock()
318 table->changed = 1; in eloop_sock_table_remove_sock()
320 eloop_trace_sock_add_ref(table); in eloop_sock_table_remove_sock()
357 if (readers && readers->table) { in eloop_sock_table_set_fds()
359 fd = readers->table[i].sock; in eloop_sock_table_set_fds()
369 if (writers && writers->table) { in eloop_sock_table_set_fds()
375 fd = writers->table[i].sock; in eloop_sock_table_set_fds()
395 if (exceptions && exceptions->table) { in eloop_sock_table_set_fds()
401 fd = exceptions->table[i].sock; in eloop_sock_table_set_fds()
419 static int eloop_sock_table_dispatch_table(struct eloop_sock_table *table, in eloop_sock_table_dispatch_table() argument
427 if (!table || !table->table) in eloop_sock_table_dispatch_table()
430 table->changed = 0; in eloop_sock_table_dispatch_table()
431 for (i = 0; i < table->count; i++) { in eloop_sock_table_dispatch_table()
432 pfd = find_pollfd(pollfds_map, table->table[i].sock, in eloop_sock_table_dispatch_table()
440 table->table[i].handler(table->table[i].sock, in eloop_sock_table_dispatch_table()
441 table->table[i].eloop_data, in eloop_sock_table_dispatch_table()
442 table->table[i].user_data); in eloop_sock_table_dispatch_table()
443 if (table->changed) in eloop_sock_table_dispatch_table()
474 static void eloop_sock_table_set_fds(struct eloop_sock_table *table, in eloop_sock_table_set_fds() argument
481 if (table->table == NULL) in eloop_sock_table_set_fds()
484 for (i = 0; i < table->count; i++) { in eloop_sock_table_set_fds()
485 assert(table->table[i].sock >= 0); in eloop_sock_table_set_fds()
486 FD_SET(table->table[i].sock, fds); in eloop_sock_table_set_fds()
491 static void eloop_sock_table_dispatch(struct eloop_sock_table *table, in eloop_sock_table_dispatch() argument
496 if (table == NULL || table->table == NULL) in eloop_sock_table_dispatch()
499 table->changed = 0; in eloop_sock_table_dispatch()
500 for (i = 0; i < table->count; i++) { in eloop_sock_table_dispatch()
501 if (FD_ISSET(table->table[i].sock, fds)) { in eloop_sock_table_dispatch()
502 table->table[i].handler(table->table[i].sock, in eloop_sock_table_dispatch()
503 table->table[i].eloop_data, in eloop_sock_table_dispatch()
504 table->table[i].user_data); in eloop_sock_table_dispatch()
505 if (table->changed) in eloop_sock_table_dispatch()
517 struct eloop_sock *table; in eloop_sock_table_dispatch() local
521 table = &eloop.epoll_table[events[i].data.fd]; in eloop_sock_table_dispatch()
522 if (table->handler == NULL) in eloop_sock_table_dispatch()
524 table->handler(table->sock, table->eloop_data, in eloop_sock_table_dispatch()
525 table->user_data); in eloop_sock_table_dispatch()
531 static void eloop_sock_table_destroy(struct eloop_sock_table *table) in eloop_sock_table_destroy() argument
533 if (table) { in eloop_sock_table_destroy()
535 for (i = 0; i < table->count && table->table; i++) { in eloop_sock_table_destroy()
539 table->table[i].sock, in eloop_sock_table_destroy()
540 table->table[i].eloop_data, in eloop_sock_table_destroy()
541 table->table[i].user_data, in eloop_sock_table_destroy()
542 table->table[i].handler); in eloop_sock_table_destroy()
545 table->table[i].handler); in eloop_sock_table_destroy()
546 wpa_trace_dump("eloop sock", &table->table[i]); in eloop_sock_table_destroy()
548 os_free(table->table); in eloop_sock_table_destroy()
586 struct eloop_sock_table *table; in eloop_register_sock() local
589 table = eloop_get_sock_table(type); in eloop_register_sock()
590 return eloop_sock_table_add_sock(table, sock, handler, in eloop_register_sock()
597 struct eloop_sock_table *table; in eloop_unregister_sock() local
599 table = eloop_get_sock_table(type); in eloop_unregister_sock()
600 eloop_sock_table_remove_sock(table, sock); in eloop_unregister_sock()