vlib: Replace timer in CLI with an event process 73/20573/3
authorChris Luke <chrisy@flirble.org>
Wed, 10 Jul 2019 03:33:30 +0000 (23:33 -0400)
committerDave Barach <openvpp@barachs.net>
Wed, 10 Jul 2019 19:05:50 +0000 (19:05 +0000)
commit6a3a4f7340bdc687814d7905ef1e4ca1a3b02d57
treed4a21d0f2c1840db6caf1eb077cbf12d3665501d
parente5a7d597782a8fc10819607e21a0d5a901343cf9
vlib: Replace timer in CLI with an event process

The CLI code, when it accepts a socket connection, ran a timer
for each session that would ensure the CLI session was started
should the TELNET negotiation stage fail to complete.

It has since transpired that this is unsafe; the timer is capable
of firing in critical sections, during a spinlock, and since we
peform non-trivial things in the handler it can cause a deadlock.

This was reported recently in VPP-1711 but a search of history
suggests this may also be (one of) the causes in VPP-1413.

This change replaces that method with an event-driven process.
The process is created when the first socket connection is
accepted.

When new connections are created the process is sent an event
to register the new session in a list. That event process has
a loop that evaluates the list of oustanding sessions and if
a deadline expires, their session is started if it has not been
already, and then removed from the list.

If we have pending sessions then the loop waits on a timer or an
event; if there are no sessions it waits on events only.

Type: fix
Ticket: VPP-1711
Change-Id: I8c6093b7d0fc1bea0eb790032ed282a0ca169194
Signed-off-by: Chris Luke <chrisy@flirble.org>
Signed-off-by: Dave Barach <dave@barachs.net>
src/vlib/unix/cli.c