From 595d5e8b54dde06d7f624d4e64458a2648477669 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 3 Aug 2023 14:24:13 -0700 Subject: modules/rkt: don't disconnect on -EINVAL from finalize It's relatively acceptable to use this hammer for the other errors like ENOMEM especially when this isn't some enterprise-y service that must endure overload conditions gracefully. But the setup_finalize() step is rather likely to find invalid settings, especially now that til_setting_t.nocheck with the ':' prefix is a thing. This commit doesn't try resume the setup at the invalid setting (yet, that will require further til_module_t.setup() method work), but it at least doesn't rudely disconnect. The user just gets dumped back to the SCENES state main prompt. --- src/modules/rkt/rkt_scener.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/rkt/rkt_scener.c b/src/modules/rkt/rkt_scener.c index 5e90eed..25650c8 100644 --- a/src/modules/rkt/rkt_scener.c +++ b/src/modules/rkt/rkt_scener.c @@ -1179,8 +1179,19 @@ int rkt_scener_update(rkt_context_t *ctxt) return rkt_scener_err_close(scener, EINVAL); /* this really shouldn't happen */ r = til_module_setup_finalize(module, scener->new_scene.settings, &setup); - if (r < 0) /* FIXME TODO we should probably un-add the scene from scenes_settings??? */ - return rkt_scener_err_close(scener, r); + if (r < 0) { /* FIXME TODO we should probably un-add the scene from scenes_settings??? */ + if (r != -EINVAL) + return rkt_scener_err_close(scener, r); + + /* FIXME TODO: error recovery needs a bunch of work, but let's not just + * hard disconnect when finalize finds invalid settings... especially + * with the addition of til_setting_t.nocheck / ':" prefixing, this is + * much more likely. + */ + scener->new_scene.settings = NULL; + + return rkt_scener_send_error(scener, EINVAL, RKT_SCENER_FSM_SEND_SCENES); + } /* have baked setup @ setup, create context using it */ r = til_module_create_context(module, -- cgit v1.2.1