Commit graph

176 commits

Author SHA1 Message Date
Felix Fietkau
8f3c5a7b50 libubus: close file descriptor after passing it in the status msg
Simplifies handling of non-deferred requests

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-02-27 16:48:55 +01:00
Karl Vogel
334c389180 ubus: Fix imbalance in lua stack push/pop of values.
The lua getglobal and rawgeti both push a value onto the lua stack,
but they weren't being removed by the ubus_method_handler function,
thus corrupting the lua stack.

In case the specified method wasn't a function, the stack was also
corrupted as the method name remained on the stack.

Signed-off-by: Karl Vogel <karl.vogel@gmail.com>
2014-02-23 18:20:29 +01:00
Felix Fietkau
54926994e2 examples/client: receive data from the passed file descriptor
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-02-18 15:03:53 +01:00
Felix Fietkau
85dff762f9 examples/server: send a file descriptor as part of the request to the "hello" method
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-02-18 15:03:53 +01:00
Felix Fietkau
47a9ab0c64 libubus: implement file descriptor passing support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-02-18 15:03:53 +01:00
Felix Fietkau
37cc5d2f25 ubusd: implement protocol support for passing file descriptors as part of request completion msgs from objects to clients
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-02-18 15:03:53 +01:00
Luka Perkov
4e82a1fabb lua: allow methods with no arguments
In C it is possible to have methods without arguments (UBUS_METHOD_NOARG).
Enable support for the same calls in Lua too.

This commit also fixes segfault which can be caused by passing non-table type
where table is expected. The lua_gettablelen() function is called after we have
made sure we are dealing with a table in the first place.

Signed-off-by: Luka Perkov <luka@openwrt.org>
2014-01-28 22:20:30 +00:00
Luka Perkov
b356773921 lua: fix whitespaces and typo
Signed-off-by: Luka Perkov <luka@openwrt.org>
2014-01-28 22:20:26 +00:00
John Crispin
29d7092252 add auto (re)connect logic to libubus
Signed-off-by: John Crispin <blogic@openwrt.org>
2014-01-22 13:53:11 +00:00
John Crispin
8ea9667036 add Lua bindings for ubus events
It mostly mimick the style of the existing code.

With it and the ubox Lua bindings, you can now send ubus events
through Lua or listen for events (you can register for multiple events
at the same time).

Signed-off-by: Jeff Remy <jeff.remy@gmail.com>
2013-11-07 16:23:30 +01:00
Felix Fietkau
a9ee3ef0cf libubus: pull the variable length data array out of struct ubus_msghdr to fix builds with clang
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-10-29 17:28:37 +01:00
Jo-Philipp Wich
6ae17d0298 ubusd: use umask of 0177 for now to prevent a world- and group-writable unix socket 2013-09-28 17:23:29 +02:00
Lukasz Baj
d486006ab9 libubus: Check if remove callback exists before call it
When process unsubscribes then remove callback is called. But it
can be NULL if not defined, so we should check it before we call it.

Signed-off-by: Lukasz Baj <l.baj@radytek.com>
2013-08-29 20:35:38 +02:00
Felix Fietkau
b20a8a01c7 libubus: detect read/write errors and set the eof flag, even if uloop is not used as main event loop
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-08-08 22:42:50 +02:00
Felix Fietkau
62bfc16a09 libubus: fix publishing objects after reconnect
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-08-08 22:20:39 +02:00
Yousong Zhou
2b4fc4c916 Add a return value to make compiler silent.
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2013-08-04 10:53:36 +02:00
Yousong Zhou
cca7fb2ab1 Fix the condition for stopping the writev_retry.
All iov's were sent only after the last were sent (iov_len == 0). We
could have 'cur_len == 0' if the sent iov's were sent wholly but not all
iov's were sent (how about all but the last).

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2013-08-04 10:53:24 +02:00
Felix Fietkau
f72dca720b libubus: fix logic inversion for cancelling requests
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-30 12:39:51 +02:00
Felix Fietkau
9f52d1769b cli: use the new json-c library name
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-29 12:53:22 +02:00
Felix Fietkau
dd3afa517d libubus: fix deadlock in recursive synchronous ubus requests
When synchronous request completion loops are running, the innermost
loop can receive events that can unblock the outer loops, however the
loop clears uloop_cancelled (which is set by the request completion).

This causes the event loop to continue running even while a completion
loop has already been unblocked.

Fix this by not clearing uloop_cancelled for inner loops

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-11 20:39:54 +02:00
Felix Fietkau
90037b772c libubus: fix crash on reconnect with objects that have no type
Signed-off-by: John Crispin <blogic@openwrt.org>
2013-04-04 22:03:24 +02:00
Felix Fietkau
47b38c98ae libubus: fix passing the return code of the subscriber callback to the notifier
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-17 18:29:38 +01:00
Felix Fietkau
460301e62d libubus: fix synchronous ubus_notify without waiting for a timeout
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-17 17:55:11 +01:00
Felix Fietkau
3b66d054cc libubus: add ubus_unregister_subscriber wrapper
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-17 03:11:35 +01:00
Felix Fietkau
495f460818 libubus: add UBUS_METHOD_NOARG
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-06 16:56:33 +01:00
Thomas Gstädtner
62cdfc3d16 add systemd support
This adds basic systemd support, incl. socket activation.
If systemd build is disabled, there won't be any sign of it neither
during build nor after.
If systemd build is enabled (default), but systemd is not available,
no systemd stuff is installed, so there is no impact whatsoever.
2013-03-04 19:11:21 +01:00
Thomas Gstädtner
29a2ed2f17 make UBUS_UNIX_SOCKET configurable via cmake
this is mainly useful to have a single location to read the setting
from, when it is used multiple times at build time (which it will in a
following patch) :)
2013-03-04 19:11:15 +01:00
Thomas Gstädtner
a15a09aed4 add INCLUDE_DIRECTORIES to subdirectories 2013-03-03 03:43:22 +01:00
Thomas Gstädtner
80d64827e9 make building examples an option 2013-03-03 03:43:06 +01:00
Felix Fietkau
82713b9d49 build: remove install prefix override
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-23 15:22:46 +01:00
Jo-Philipp Wich
bf566871bd lua: pass u64 blob type as double to Lua 2013-01-13 20:37:19 +01:00
Felix Fietkau
7c140855d9 libubus: free internal blob_buf memory when freeing an ubus context
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-30 14:14:22 +01:00
Felix Fietkau
bb856ad8a9 examples: disable the message on the server example, measure the notify latency on the client example
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 16:52:03 +01:00
Felix Fietkau
3642af8097 libubus: fix data type of request sequence counter. fixes hang after ~64K requests
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 16:51:28 +01:00
Felix Fietkau
4b9ed896cf libubus: fix uninitialized variable warning
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 14:11:15 +01:00
Felix Fietkau
54c78ed905 examples: use blocking notify
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 00:37:26 +01:00
Felix Fietkau
f3fabd45a7 libubus: implement notify handling
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 00:37:09 +01:00
Felix Fietkau
c2158ae53c libubus: fix segfaults on request timeouts
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 00:35:12 +01:00
Felix Fietkau
79c40c95db ubusd: implement notify forwarding with status reporting
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 00:32:27 +01:00
Felix Fietkau
e9431842e2 libubus: check if subscriber cb is non-NULL before calling it
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 21:27:52 +01:00
Felix Fietkau
ee9e399096 libubus: do not send a status reply if UBUS_ATTR_NO_REPLY is set
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 20:05:34 +01:00
Felix Fietkau
154a87c683 libubus: add UBUS_ATTR_NO_REPLY and add policy for UBUS_ATTR_ACTIVE
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 20:05:06 +01:00
Felix Fietkau
2224658580 move ubus_start_request to libubus-req.c
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 19:48:26 +01:00
Felix Fietkau
1579969983 libubus: remove accidentally committed unused header file
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 14:14:43 +01:00
Felix Fietkau
2cae3fb422 libubus: refactor code, move request handling to libubus-req.c
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 14:13:27 +01:00
Felix Fietkau
7cd33a8e3a libubus: reduce code duplication and add stack depth protection for unsubscribe/notify callbacks
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 13:42:10 +01:00
Felix Fietkau
0fccce4445 remove the "method" argument for object subscription
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 13:11:40 +01:00
Felix Fietkau
a69f062cbd ubus: add notification for subscribers present/gone
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-14 13:00:57 +01:00
Felix Fietkau
d366a6de83 watch add/remove -> subscribe/unsubscribe:
rename the ADD_WATCH/REMOVE_WATCH messages to SUBSCRIBE/UNSUBSCRIBE and change
the message format and libubus API in preparation for adding object notifications

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-13 19:35:38 +01:00
Felix Fietkau
43d6047c40 ubusd: use avl_strcmp
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-11 23:38:00 +01:00