Avoid clobbering output_function by concurrent CLI sessions doing vlib_process_wait_f... 48/1048/4
authorAndrew Yourtchenko <ayourtch@gmail.com>
Tue, 10 May 2016 10:51:34 +0000 (10:51 +0000)
committerDave Barach <openvpp@barachs.net>
Tue, 10 May 2016 17:13:00 +0000 (17:13 +0000)
commit716d9593497388c48593f818748faf705ac7169e
tree50dd1adea16bcff1ab80494532c5603bcf44de5e
parent46d4e36792e829ef96b43dbc6eec344700d54f13
Avoid clobbering output_function by concurrent CLI sessions doing vlib_process_wait_for_event*.

A problem is easily reproducible by taking the test harness code from the commit,
and launching it in two terminals with some time overlap - the outputs will
be sent to the wrong session. This commit moves the output_function and argument
from a global structure into the process structure, thus the output_function
is not clobbered anymore and each session gets only its own output.

To ensure the callers can redirect the outputs to different destinations
(e.g. the API calls via shared memory, etc.) the existing logic
for vlib_cli_input() was retained.

To avoid the magic numbers usage in the logic that does the page-alignment
of the process stack, there are changes around the stack[] member
of vlib_process_t. Also added a compile-time assert to ensure that
the stack does indeed start on the page size multiple boundary.

Change-Id: I128680ac480735e5f214f81a884e414268e5d652
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
vlib/vlib/cli.c
vlib/vlib/cli.h
vlib/vlib/node.h
vlib/vlib/unix/cli.c