Lines Matching refs:fds
163 static void setup_poll(const struct context *ctx, struct pollfd *fds, size_t n) in setup_poll() argument
166 fds[i].fd = ctx[i].spair[0]; in setup_poll()
167 fds[i].events = POLLIN; in setup_poll()
168 fds[i].revents = 0; in setup_poll()
172 static int handle_poll_events(const struct context *ctx, struct pollfd *fds, size_t n, in handle_poll_events() argument
181 idx = fd_to_idx(fds[i].fd, ctx, n); in handle_poll_events()
183 printf("failed to find fd %d in any active context\n", fds[i].fd); in handle_poll_events()
187 if ((fds[i].revents & POLLERR) != 0) { in handle_poll_events()
188 printf("fd: %d: error\n", fds[i].fd); in handle_poll_events()
190 } else if ((fds[i].revents & POLLIN) != 0) { in handle_poll_events()
194 res = read(fds[i].fd, buf, sizeof(buf)); in handle_poll_events()
200 printf("main: read '%s' on fd %d\n", buf, fds[i].fd); in handle_poll_events()
206 res = write(fds[i].fd, buf, res); in handle_poll_events()
228 struct pollfd fds[NUM_SOCKETPAIRS] = {}; in main() local
238 setup_poll(ctx, fds, NUM_SOCKETPAIRS); in main()
239 res = poll(fds, NUM_SOCKETPAIRS, -1); in main()
245 res = handle_poll_events(ctx, fds, NUM_SOCKETPAIRS, res); in main()