aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/unix/input.c22
-rw-r--r--src/vlib/unix/main.c2
-rw-r--r--src/vlib/unix/unix.h3
3 files changed, 25 insertions, 2 deletions
diff --git a/src/vlib/unix/input.c b/src/vlib/unix/input.c
index 321e443dee9..0a61c05d471 100644
--- a/src/vlib/unix/input.c
+++ b/src/vlib/unix/input.c
@@ -148,9 +148,27 @@ linux_epoll_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
int timeout_ms = 0, max_timeout_ms = 10;
f64 vector_rate = vlib_last_vectors_per_main_loop (vm);
+ /*
+ * If we've been asked for a fixed-sleep between main loop polls,
+ * do so right away.
+ */
+ if (PREDICT_FALSE (is_main && um->poll_sleep_usec))
+ {
+ struct timespec ts, tsrem;
+ timeout = 0;
+ timeout_ms = 0;
+ node->input_main_loops_per_call = 0;
+ ts.tv_sec = 0;
+ ts.tv_nsec = 1000 * um->poll_sleep_usec;
+
+ while (nanosleep (&ts, &tsrem) < 0)
+ {
+ ts = tsrem;
+ }
+ }
/* If we're not working very hard, decide how long to sleep */
- if (is_main && vector_rate < 2 && vm->api_queue_nonempty == 0
- && nm->input_node_counts_by_state[VLIB_NODE_STATE_POLLING] == 0)
+ else if (is_main && vector_rate < 2 && vm->api_queue_nonempty == 0
+ && nm->input_node_counts_by_state[VLIB_NODE_STATE_POLLING] == 0)
{
ticks_until_expiration = TW (tw_timer_first_expires_in_ticks)
((TWT (tw_timer_wheel) *) nm->timing_wheel);
diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c
index 786addf2e0a..f812b080f07 100644
--- a/src/vlib/unix/main.c
+++ b/src/vlib/unix/main.c
@@ -344,6 +344,8 @@ unix_config (vlib_main_t * vm, unformat_input_t * input)
um->cli_no_banner = 1;
else if (unformat (input, "cli-no-pager"))
um->cli_no_pager = 1;
+ else if (unformat (input, "poll-sleep-usec %d", &um->poll_sleep_usec))
+ ;
else if (unformat (input, "cli-pager-buffer-limit %d",
&um->cli_pager_buffer_limit))
;
diff --git a/src/vlib/unix/unix.h b/src/vlib/unix/unix.h
index 4c8566b7ee8..7856e5b7df7 100644
--- a/src/vlib/unix/unix.h
+++ b/src/vlib/unix/unix.h
@@ -102,6 +102,9 @@ typedef struct
/* Store the original state of stdin when it's a tty */
struct termios tio_stdin;
int tio_isset;
+
+ u32 poll_sleep_usec;
+
} unix_main_t;
/* Global main structure. */