MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ff_hook_select

Function ff_hook_select

adapter/syscall/ff_hook_syscall.c:2610–2917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2608}
2609
2610int
2611ff_hook_select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds,
2612 fd_set *restrict exceptfds, struct timeval *restrict timeout)
2613{
2614 int set_words;
2615 int set_bytes;
2616 int fd;
2617 int max_kernel_fd = 0;
2618 int max_ff_fd = 0;
2619 fd_mask *fds_bit;
2620 struct timespec t_s, t_n;
2621 time_t now_time_ms = 0;
2622 time_t end_time_ms = 0;
2623 int ff_set_words, ff_set_bytes = 0;
2624 int kernel_set_words, kernel_set_bytes = 0;
2625 int kernel_ret = 0;
2626
2627 DEBUG_LOG("ff_hook_select nfds:%d\n", nfds);
2628
2629 DEFINE_REQ_ARGS_STATIC(select);
2630 static __thread fd_set *ff_readfds_share = NULL;
2631 static __thread fd_set *ff_writefds_share = NULL;
2632 static __thread fd_set *ff_exceptfds_share = NULL;
2633 static __thread fd_set kernel_readfds;
2634 static __thread fd_set kernel_writefds;
2635 static __thread fd_set kernel_exceptfds;
2636 static __thread fd_set ff_readfds;
2637 static __thread fd_set ff_writefds;
2638 static __thread fd_set ff_exceptfds;
2639
2640 bool have_ff_readfd = false;
2641 bool have_ff_writefd = false;
2642 bool have_ff_exceptfd = false;
2643 bool have_kernel_fd = false;
2644 bool have_exec_kernel_select = false;
2645
2646 if (nfds > FD_SETSIZE) {
2647 nfds = FD_SETSIZE;
2648 }
2649
2650 if (ff_kernel_max_fd >= FD_SETSIZE) {
2651 return ff_linux_select(nfds, readfds, writefds, exceptfds, timeout);
2652 }
2653
2654 set_words = (nfds + NFDBITS - 1) / NFDBITS;
2655 set_bytes = set_words * sizeof(fd_mask);
2656
2657 if (ff_readfds_share == NULL) {
2658 ff_readfds_share = share_mem_alloc(sizeof(fd_set));
2659 if (ff_readfds_share == NULL) {
2660 RETURN_ERROR_NOFREE(ENOMEM);
2661 }
2662 }
2663
2664 if (ff_writefds_share == NULL) {
2665 ff_writefds_share = share_mem_alloc(sizeof(fd_set));
2666 if (ff_writefds_share == NULL) {
2667 RETURN_ERROR_NOFREE(ENOMEM);

Callers

nothing calls this directly

Calls 8

ff_linux_selectFunction · 0.85
memsetFunction · 0.85
ff_bitmap_first_setFunction · 0.85
ff_bitmap_next_setFunction · 0.85
is_fstack_fdFunction · 0.70
restore_fstack_fdFunction · 0.70
convert_fstack_fdFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected