Lines Matching defs:selector
68 tunala_selector_t selector;
94 static void selector_init(tunala_selector_t * selector);
95 static void selector_add_listener(tunala_selector_t * selector, int fd);
96 static void selector_add_tunala(tunala_selector_t * selector,
98 static int selector_select(tunala_selector_t * selector);
103 static int selector_get_listener(tunala_selector_t * selector, int fd,
109 static int tunala_item_io(tunala_selector_t * selector, tunala_item_t * item);
565 selector_init(&world.selector);
571 selector_add_listener(&world.selector, world.listen_fd);
574 selector_add_tunala(&world.selector, world.tunnels + loop);
576 switch (selector_select(&world.selector)) {
582 fprintf(stderr, "Warn, selector interrupted by a signal\n");
592 && (selector_get_listener(&world.selector, world.listen_fd, &newfd) ==
610 if (!tunala_item_io(&world.selector, t_item)) {
897 static void selector_init(tunala_selector_t * selector)
899 selector_sets_init(&selector->last_selected);
900 selector_sets_init(&selector->next_select);
918 static void selector_add_listener(tunala_selector_t * selector, int fd)
920 selector_add_raw_fd(selector, fd, SEL_READS);
955 static int selector_select(tunala_selector_t * selector)
957 memcpy(&selector->last_selected, &selector->next_select,
959 selector_sets_init(&selector->next_select);
960 return select(selector->last_selected.max,
961 &selector->last_selected.reads,
962 &selector->last_selected.sends,
963 &selector->last_selected.excepts, NULL);
970 static int selector_get_listener(tunala_selector_t * selector, int fd,
973 if (FD_ISSET(fd, &selector->last_selected.excepts))
975 if (!FD_ISSET(fd, &selector->last_selected.reads))
1079 static int tunala_item_io(tunala_selector_t * selector, tunala_item_t * item)
1085 &selector->
1089 &selector->
1093 &selector->
1097 &selector->
1103 c_r = FD_ISSET(item->clean_read, &selector->last_selected.reads);
1105 c_s = FD_ISSET(item->clean_send, &selector->last_selected.sends);
1107 d_r = FD_ISSET(item->dirty_read, &selector->last_selected.reads);
1109 d_s = FD_ISSET(item->dirty_send, &selector->last_selected.sends);