summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-04-03 16:51:49 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2018-04-05 03:11:49 +0200
commitcdbc9afe5da5fe728ce8fa62e36ded17efe70032 (patch)
tree5d1980f1c46409ec441557acaf66897295aedf84 /tests
parent6882b80d9630293f7db7606b1d73194d0571e6a4 (diff)
ctrl: fix deferred commands (and hence fix osmo-bts-sysmo 'clock-info' cmd)
The CTRL interface has a ctrl_cmd_def_* API that allows deferring a CTRL command reply until later. However, the command handling currently fails to acknowledge this and deallocates the struct ctrl_cmd anyway. Fix: in struct ctrl_cmd, add a defer pointer to be populated by ctrl_cmd_def_make(). A cmd thus marked as deferred is not deallocated at the end of command handling. This fix needs no change in calling code. (Another idea was to return a different code than CTRL_CMD_HANDLED when the command is to be deferred, but that would require adjusting each user of ctrl_cmd_def_make(). The implicit marking is safer and easier.) Show that handling deferred commands is fixed by adjusting the expectations of ctrl_test.c's test_deferred_cmd() and removing the now obsolete exit_early label. One symptom of the breakage is that osmo-bts-sysmo crashes when asked to report a trx's clock-info, which is aggravated by the fact that the sysmobts-mgr does ask osmo-bts-sysmo for a clock-info. The crash appears since Id583b413f8b8bd16e5cf92a8a9e8663903646381 -- it looked like just fixing an obvious memory leak, which it did as shown by the unit test, but deferred ctrl commands actually relied on that leak. Both fixed now. Related: OS#3120 Change-Id: I24232be7dcf7be79f4def91ddc8b8f8005b56318
Diffstat (limited to 'tests')
-rw-r--r--tests/ctrl/ctrl_test.c4
-rw-r--r--tests/ctrl/ctrl_test.ok3
2 files changed, 2 insertions, 5 deletions
diff --git a/tests/ctrl/ctrl_test.c b/tests/ctrl/ctrl_test.c
index f20f534c..b7b30c3e 100644
--- a/tests/ctrl/ctrl_test.c
+++ b/tests/ctrl/ctrl_test.c
@@ -401,8 +401,6 @@ static void test_deferred_cmd()
/* Expecting a ctrl_cmd_def as well as the cmd to still be allocated */
if (talloc_total_size(ctx) <= ctx_size_before_defer) {
printf("deferred command apparently deallocated too soon\n");
- /* ERROR -- showing current bug in handling deallocated cmds, hence exiting early */
- goto exit_early;
talloc_report_full(ctx, stdout);
OSMO_ASSERT(false);
}
@@ -417,8 +415,6 @@ static void test_deferred_cmd()
OSMO_ASSERT(false);
}
-exit_early:
-
talloc_free(ccon);
talloc_free(ctrl);
diff --git a/tests/ctrl/ctrl_test.ok b/tests/ctrl/ctrl_test.ok
index 6a902be0..07f4aac5 100644
--- a/tests/ctrl/ctrl_test.ok
+++ b/tests/ctrl/ctrl_test.ok
@@ -176,5 +176,6 @@ ok
test_deferred_cmd
get_test_defer called
ctrl_handle_msg() returned 0
-deferred command apparently deallocated too soon
+invoking ctrl_test_defer_cb() asynchronously
+ctrl_test_defer_cb called
success