47 #define HAVE_LINUX_EPOLL 49 #ifdef HAVE_LINUX_EPOLL 51 #include <sys/epoll.h> 73 struct epoll_event e = { 0 };
140 struct epoll_event *e;
142 int is_main = (thread_index == 0);
146 u32 ticks_until_expiration;
148 int timeout_ms = 0, max_timeout_ms = 10;
152 if (is_main && vector_rate < 2 && vm->api_queue_nonempty == 0
155 ticks_until_expiration =
TW (tw_timer_first_expires_in_ticks)
162 timeout_ms = max_timeout_ms;
166 timeout = (
f64) ticks_until_expiration *1e-5;
171 timeout_ms = timeout * 1e3;
173 timeout_ms =
clib_max (1, timeout_ms);
174 timeout_ms =
clib_min (max_timeout_ms, timeout_ms);
179 else if (is_main == 0 && vector_rate < 2 &&
183 timeout_ms = max_timeout_ms;
195 static sigset_t unblock_all_signals;
196 n_fds_ready = epoll_pwait (em->
epoll_fd,
199 timeout_ms, &unblock_all_signals);
202 if (n_fds_ready < 0 && errno == ENOSYS)
204 n_fds_ready = epoll_wait (em->
epoll_fd,
212 usleep (timeout_ms * 1000);
229 for (e = em->
epoll_events; e < em->epoll_events + n_fds_ready; e++)
238 if (e->events & EPOLLIN)
242 n_errors += errors[n_errors] != 0;
244 if (e->events & EPOLLOUT)
248 n_errors += errors[n_errors] != 0;
257 n_errors += errors[n_errors] != 0;
264 for (i = 0; i < n_errors; i++)
279 if (thread_index == 0)
289 .name =
"unix-epoll-input",
309 if (linux_epoll_mains == em)
#define UNIX_FILE_EVENT_EDGE_TRIGGERED
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
static void vlib_panic_with_error(vlib_main_t *vm, clib_error_t *error)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
static u32 vlib_last_vectors_per_main_loop(vlib_main_t *vm)
clib_file_function_t * read_function
u32 input_main_loops_per_call
For input nodes: decremented on each main loop interation until it reaches zero and function is calle...
#define static_always_inline
#define VLIB_INIT_FUNCTION(x)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
clib_file_main_t file_main
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
#define vlib_call_init_function(vm, x)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define clib_error_return_unix(e, args...)
#define TW_SLOTS_PER_RING
void(* file_update)(clib_file_t *file, clib_file_update_type_t update_type)
#define VLIB_REGISTER_NODE(x,...)
static_always_inline uword vlib_get_thread_index(void)
#define clib_warning(format, args...)
static word unix_error_is_fatal(word error)
#define UNIX_FILE_DATA_AVAILABLE_TO_WRITE
struct epoll_event * epoll_events
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 input_node_counts_by_state[VLIB_N_NODE_STATE]
vlib_node_main_t node_main
#define clib_unix_warning(format, args...)
clib_file_function_t * error_function
static vlib_thread_main_t * vlib_get_thread_main()
static void unix_save_error(unix_main_t *um, clib_error_t *error)
#define vec_foreach(var, vec)
Vector iterator.
#define CLIB_CACHE_LINE_BYTES
clib_file_function_t * write_function