aboutsummaryrefslogtreecommitdiffstats
path: root/ucs2-afb
diff options
context:
space:
mode:
authorFulup Ar Foll <fulup@iot.bzh>2017-07-13 23:43:04 +0200
committerGitHub <noreply@github.com>2017-07-13 23:43:04 +0200
commit2d039f447c2b91ae5e41406238eea3950436c714 (patch)
treeb3e010b515b4bdee22e316e410efe418a8bfa84d /ucs2-afb
parentb64500c1e9bc55e273bb57b8423b8c3d4f0ead83 (diff)
parent6e087e84f5faef8c5dd20e337cd88171931bdaff (diff)
Merge pull request #4 from tkummermehr/EnableXmlReloading
Fix non working reloading of new XML files via WebSocket
Diffstat (limited to 'ucs2-afb')
-rw-r--r--ucs2-afb/ucs_binding.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/ucs2-afb/ucs_binding.c b/ucs2-afb/ucs_binding.c
index ba49e20..c451bf3 100644
--- a/ucs2-afb/ucs_binding.c
+++ b/ucs2-afb/ucs_binding.c
@@ -439,36 +439,38 @@ PUBLIC void ucs2Init (struct afb_req request) {
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");