[LEDE-DEV] ubus rpcd plugins
Karl Palsson
karlp at tweak.net.au
Thu Sep 29 08:49:42 PDT 2016
Hi, I've been trying to implement a firmware update via a ubus
rpcd plugin, and have run into a problem regarding how ubus calls
the plugins. As best I can tell, if a ubus rpcd plugin does
_anything_ in the background, ubus call hangs and then timesout.
I can see that rpcd already has some attempts at sysupgrade
support, where it forks, explicitly to avoid this [1] but even
with a lua ubus rcpd plugin forking, I see the same behaviour
with fork, or with shell &.
Example output below..
```
# ubus list -v demo-hang
'demo-hang' @e96d29a7
"gofork":{"fname":"String"}
"simple":{"fname":"String"}
# ubus call demo-hang simple
{
"simple": "went fine"
}
# ubus call demo-hang gofork
Command failed: Request timed out
```
Sample rpcd plugin handler:
```
#!/bin/sh
case "$1" in
list)
echo '{ "gofork": { "fname": "somestring" }, "simple": { "fname": "somestring" } }'
;;
call)
case "$2" in
simple)
read input;
printf "simple called with input <%s>\n" "$input" >> /tmp/demo-hang.log
echo '{ "simple": "went fine" }'
;;
gofork)
read input;
printf "gofork called with input <%s>\n" "$input" >> /tmp/demo-hang.log
# fork and let the child do some long running task
(sleep 3; echo "after sleeping, child wrote this" >> /tmp/demo-hang.log)&
echo '{ "gofork": "went fine" }'
;;
esac
;;
esac
```
The log file written has the child output included, so it's
clearly running. Is there any method of starting a task from a
rpcd plugin like this? Even in my own case, I can't use the
"existing" rpcd sysupgrade support, because it's not available on
the CC branch, and there's been no releases of anything later.
Sincerely,
Karl Palsson
[1] RPCD forking to do background task:
https://git.lede-project.org/?p=project/rpcd.git;a=blob;f=sys.c;h=b90aa6b894aba29e8be4884c160a7c34ee0ca646;hb=HEAD#l189
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP Digital Signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20160929/cc2261a9/attachment.sig>
More information about the Lede-dev
mailing list