From 6e087e84f5faef8c5dd20e337cd88171931bdaff Mon Sep 17 00:00:00 2001 From: tkummermehr Date: Thu, 13 Jul 2017 21:36:16 +0200 Subject: Fixed non working reloading of new XML files via WebSocket --- ucs2-afb/ucs_binding.c | 52 ++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'ucs2-afb') diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c index c1a0a06..48a333e 100644 --- a/ucs2-afb/ucs_binding.c +++ b/ucs2-afb/ucs_binding.c @@ -446,40 +446,42 @@ PUBLIC void ucs2Init (struct afb_req request) { sd_event_source *evtSource; int err; - // Read and parse XML file + /* Read and parse XML file */ ucsConfig = ParseFile (request); if (NULL == ucsConfig) goto OnErrorExit; - // Fulup->Thorsten BUG InitializeCdevs should fail when control does not exit - if (!InitializeCdevs(&ucsContext)) { - afb_req_fail_f (request, "devnit-error", "Fail to initialise device [rx=%s tx=%s]", CONTROL_CDEV_RX, CONTROL_CDEV_TX); - goto OnErrorExit; - } + /* When ucsContextS is set, do not initalize UNICENS, CDEVs or system hooks, just load new XML */ + if (!ucsContextS) + { + if (!ucsContextS && !InitializeCdevs(&ucsContext)) { + afb_req_fail_f (request, "devnit-error", "Fail to initialise device [rx=%s tx=%s]", CONTROL_CDEV_RX, CONTROL_CDEV_TX); + goto OnErrorExit; + } - // Initialise Unicens Config Data Structure - UCSI_Init(&ucsContext.ucsiData, &ucsContext); + /* Initialise UNICENS Config Data Structure */ + UCSI_Init(&ucsContext.ucsiData, &ucsContext); - // Initialise Unicens with parsed config - if (!UCSI_NewConfig(&ucsContext.ucsiData, ucsConfig)) { - afb_req_fail_f (request, "UNICENS-init", "Fail to initialize Unicens"); - goto OnErrorExit; - } + /* register aplayHandle file fd into binder mainloop */ + err = sd_event_add_io(afb_daemon_get_event_loop(afbIface->daemon), &evtSource, ucsContext.rx.fileHandle, EPOLLIN, onReadCB, &ucsContext); + if (err < 0) { + afb_req_fail_f (request, "register-mainloop", "Cannot hook events to mainloop"); + goto OnErrorExit; + } - // register aplayHandle file fd into binder mainloop - err = sd_event_add_io(afb_daemon_get_event_loop(afbIface->daemon), &evtSource, ucsContext.rx.fileHandle, EPOLLIN, onReadCB, &ucsContext); - if (err < 0) { - afb_req_fail_f (request, "register-mainloop", "Cannot hook events to mainloop"); - goto OnErrorExit; + /* init UNICENS Volume Library */ + ucsContext.channels = UCSI_Vol_Init (&ucsContext.ucsiData, volumeCB); + if (!ucsContext.channels) { + afb_req_fail_f (request, "register-volume", "Could not enqueue new Unicens config"); + goto OnErrorExit; + } + /* save this in a statical variable until ucs2vol move to C */ + ucsContextS = &ucsContext; } - - // init Unicens Volume Library - ucsContext.channels = UCSI_Vol_Init (&ucsContext.ucsiData, volumeCB); - if (!ucsContext.channels) { - afb_req_fail_f (request, "register-volume", "Could not enqueue new Unicens config"); + /* Initialise UNICENS with parsed config */ + if (!UCSI_NewConfig(&ucsContext.ucsiData, ucsConfig)) { + afb_req_fail_f (request, "UNICENS-init", "Fail to initialize UNICENS"); goto OnErrorExit; } - // save this in a statical variable until ucs2vol move to C - ucsContextS = &ucsContext; afb_req_success(request,NULL,"UNICENS-active"); -- cgit 1.2.3-korg