Skip to content

ubus deferred request enhancements#282

Merged
jow- merged 5 commits intojow-:masterfrom
nbd168:ubus
Mar 16, 2025
Merged

ubus deferred request enhancements#282
jow- merged 5 commits intojow-:masterfrom
nbd168:ubus

Conversation

@nbd168
Copy link
Copy Markdown
Contributor

@nbd168 nbd168 commented Mar 4, 2025

Improve support for deferring and handling deferred requests

  • allow sending and receiving multiple reply messages
  • allow sending requests without waiting for a response
  • add defer support for channels
  • fix broken defer() API footgun

@nbd168 nbd168 force-pushed the ubus branch 2 times, most recently from ecde3b2 to d94c0c9 Compare March 7, 2025 13:42
@nbd168
Copy link
Copy Markdown
Contributor Author

nbd168 commented Mar 12, 2025

@jow- any comments? I need this PR for a new package that I intend to push soon.

Comment thread lib/ubus.c Outdated
Comment thread lib/ubus.c Outdated
Comment thread lib/ubus.c
Comment thread lib/ubus.c Outdated
jow- and others added 5 commits March 16, 2025 23:58
Add a local helper macro errval_return() which sets a local error code
and returns it. Also do some minor whitespace and code style fixes while
we're at it.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Works in the same way as regular defer calls, except that it operates on
channels.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
[use errval_return(), minor whitespace changes]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
When passing UBUS_STATUS_CONTINUE (or -1) in the return code argument, assume
that more reply calls are coming and only send a reply data message without
the status code.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
[minor whitespace changes]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
…op.run()

Calling ubus.defer() outside of uloop.run() was apparently broken since commit
1cb04f9 ("ubus: add object publishing, notify and subscribe support") from
March 2022.

It was supposed to block until the request completes, however it blocked forever
due to a counter imbalance introduced by the above commit.

These days this 'feature' is of questionable value, since req.await() exists,
and there is a legitimate use for issuing deferred requests from outside of
uloop.run() and then calling uloop.run() or req.await() afterwards.

Since nobody noticed the breakage in all this time, let's just get rid of
this API footgun.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Explicitly zero-initialize `obi` in `_args_get()` to avoid the following
compiler warning:

    .../ubus.c: In function ‘_args_get’:
    .../ubus.c:100:31: error: ‘obj’ may be used uninitialized [-Werror=maybe-uninitialized]
      100 |                         arg = ucv_object_get(obj, name, NULL);
          |                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
@jow- jow- merged commit c4d7f91 into jow-:master Mar 16, 2025
@jow-
Copy link
Copy Markdown
Owner

jow- commented Mar 16, 2025

Merged with some code style adjustments, thanks!

@nbd168 nbd168 deleted the ubus branch March 21, 2025 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants