Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit


to look at the new patch set (#2).

ensure that osmo_fsm vty commands are only installed once

There is a desire to install osmo_fsm vty commands automatically in
a library context, rather than requiring every application which
directly or indirectly uses osmo_fsm to run osmo_fsm_vty_add_cmd().

However, the function install_element_ve() asserts that elements
about to be installed have not already been installed.

This means we cannot shift responsibility into a library context
without first making sure that osmo_fsm commands are only installed
once per combined application+library context, because applications
won't know which commands any of its libraries has already installed.

A simple solution is to use a global flag which is checked by
osmo_fsm_vty_add_cmd() before installing osmo_fsm commands, and
is set once the commands have been installed. This way, no harm
is done if osmo_fsm_vty_add_cmd() is called multiple times.

Change-Id: I10b0b1c1c1bf44c3b8eafc465c1ee06ea2590682
Related: OS#2967
M src/vty/fsm_vty.c
1 file changed, 12 insertions(+), 0 deletions(-)

  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/43/6843/2

diff --git a/src/vty/fsm_vty.c b/src/vty/fsm_vty.c
index 8abb9c9..2947678 100644
--- a/src/vty/fsm_vty.c
+++ b/src/vty/fsm_vty.c
@@ -181,8 +181,20 @@
  *  application if you want to support those commands. */
 void osmo_fsm_vty_add_cmds(void)
+       static bool osmo_fsm_vty_cmds_installed;
+       /* Make sure FSM commands get installed only once.
+        * We might be called from libraries or from an application.
+        * An application might be oblivious to the fact that one or
+        * more of its libaries are using osmo_fsm. And likewise,
+        * any given library will not know if another library has
+        * already installled these commands. */
+       if (osmo_fsm_vty_cmds_installed)
+               return;
+       osmo_fsm_vty_cmds_installed = true;

To view, visit https://gerrit.osmocom.org/6843
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I10b0b1c1c1bf44c3b8eafc465c1ee06ea2590682
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Stefan Sperling <ssperl...@sysmocom.de>
Gerrit-Reviewer: Harald Welte <lafo...@gnumonks.org>
Gerrit-Reviewer: Jenkins Builder

Reply via email to