Commit graph

65 commits

Author SHA1 Message Date
Felix Fietkau
cd82f9758d libubus: move uloop_init() call to ubus_connect_ctx
uloop should not be used before it is initialized

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2017-01-22 14:28:49 +01:00
Abhimanyu Vishwakarma
ad5333a73b ubus: ubus_free: clear pending timers before freeing context
If a synchronous operation is executed on a ubus context after
uloop_done() has been called, the context's pending_timer
may remain in uloop's list of timeouts.
This leads to undefined behaviour during next execution of uloop
code, as it may be referring to unavailable memory or memory
that has been allocated for different purposes.

Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Signed-off-by: Abhimanyu Vishwakarma <Abhimanyu.Vishwakarma@imgtec.com>
2017-01-04 22:02:43 +01:00
amine ahd
df088f03c0 Allow sending a fd along a ubus_request
Signed-off-by: amine.ahd <amine.ahd@gmail.com>
2016-12-24 14:31:04 +01:00
Eyal Birger
3b8d4b5653 libubus: nullify stale msgbuf pointer in case of ubus_connect_ctx() failure
If the ubus_reconnect() call fails in ubus_connect_ctx(), the msgbuf.data
newly allocated buffer is freed, but its pointer in the ubus_context is not
removed.

This leads to a double free error if ubus_auto_shutdown() is called for cleanup
after ubus_auto_connect() failed to connect to ubusd.

Signed-off-by: Eyal Birger <eyal.birger@gmail.com>
2016-05-15 09:39:24 +02:00
Alexandru Ardelean
85e4de4193 libubus: add null for ubus_context object in ubus_shutdown()
At the moment, we do our own null checks before calling ubus_free().
The likely-hood of 'ctx' being null (in ubus_free()) is low,
but since free() handles null, might make sense for ubus_free() to do so as well.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2015-12-19 12:29:23 +01:00
Felix Fietkau
44a62711e0 libubus: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-19 22:32:25 +01:00
Hans Dedecker
95648dadba libubus: Fix reverse order processing of pending ubus notifications messages
Append ubus notification messages to the tail of the pending list
so they're processed in the order as they're put onto the pending list

Signed-off-by: Xinxing Hu <xinxing.huchn@gmail.com>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
2015-11-02 19:02:53 +01:00
Delio Brignoli
7b79b6226e libubus: expose ubus_connect_ctx() in public API
ubus_connect_ctx() is equivalent to ubus_connect() but accepts a
pointer to a previously allocated ubus_context struct.
ubus_shutdown() is made available as an alternative to ubus_free()
to clean up contexts initialised by ubus_connect_ctx().

Signed-off-by: Delio Brignoli <dbrignoli@audioscience.com>
2014-10-14 09:57:11 +02:00
Felix Fietkau
3e45a782b2 libubus: remove ubus_msghdr_data() by passing in the right data structure pointer
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:33:27 +02:00
Felix Fietkau
7c25c119a5 libubus: use calloc_a for queued msgs to reduce the number of allocations
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-15 15:21:40 +02:00
Felix Fietkau
73cbb94b48 libubus: fix a small memleak in ubus_register_event_handler()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-04 20:01:13 +02:00
Alexandru Ardelean
6d24ad71f6 ubus: increase message size limit and make it configurable at build-time 2014-07-03 12:44:19 +02:00
Alexandru Ardelean
7e746e5a85 libubus: refactor ubus_context msgbuf data to be dynamically allocated 2014-07-03 12:42:42 +02:00
Felix Fietkau
3869e0ca07 libubus: fix deferring invoke processing for non-uloop usage
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-06-25 10:24:27 +02:00
Felix Fietkau
bbd3fbc9cc libubus: always defer processing incoming invoke/unsubscribe/notify if there is a request pending
This fixes recursion problems on config reload in netifd and simplifies
application handling of requests

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-06-24 22:34:53 +02: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
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
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
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
f3fabd45a7 libubus: implement notify handling
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-15 00:37:09 +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
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
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
a6f52f058e libubus: split out some code into separate source files 2012-10-24 15:07:35 +02:00
Felix Fietkau
7864896a1b add support for deferring a reply to a method invoke call 2012-10-01 14:09:19 +02:00
Felix Fietkau
34161692fa libubus: add support for reconnecting (and re-publishing objects) 2012-05-29 00:56:37 +02:00
Felix Fietkau
c6f7054515 ubusd: add support for watching objects to get notified when they go away 2012-05-19 21:09:35 +02:00
Felix Fietkau
8e5a6af1db libubus: limit stack depth for incoming invoke requests 2011-10-27 14:03:19 +02:00
Felix Fietkau
f07b02b560 libubus: fix recursive synchrnonous invoke commands 2011-10-27 13:46:05 +02:00
Felix Fietkau
1ad3493658 fix invalid message reuse in ubus_process_invoke 2011-10-10 16:47:49 +02:00
Felix Fietkau
7c59d4069c make the socket non-blocking, explicitly wait for data using poll() 2011-09-09 17:53:22 +02:00
Felix Fietkau
cc82d89995 add an error message for "unknown error" 2011-09-05 03:20:07 +02:00
Felix Fietkau
24505f172a add an error code for "operation not supported" 2011-09-05 03:16:59 +02:00
Felix Fietkau
42bc27ae38 add copyright/license information 2011-06-17 16:35:11 +02:00
Felix Fietkau
e49b34f912 simplify object signatures by reusing the parser policy to define them 2011-03-27 20:03:18 +02:00
Felix Fietkau
f2ee96c51d add support for timeouts on synchronous requests 2011-02-11 02:40:39 +01:00
Felix Fietkau
fb45e383c2 remove separate catch all list, always require a pattern argument for registering events, even if it is just * 2011-02-11 01:21:07 +01:00
Felix Fietkau
756d284a0a add writev_retry to avoid incomplete writes 2011-02-11 00:36:10 +01:00
Felix Fietkau
12a8f978cb add sender side length checks 2011-02-07 02:35:24 +01:00
Felix Fietkau
4ab6155577 remove unnecessary debug stuff 2011-02-07 02:09:37 +01:00
Felix Fietkau
b0755698c1 fix max message length handling - exclude the header 2011-02-07 01:52:40 +01:00
Felix Fietkau
f9f602533a add code for sending events and fix the code for receiving events 2011-02-07 01:25:28 +01:00
Felix Fietkau
a93b044d6a make ubus_default_connection_lost static 2011-02-07 00:07:59 +01:00
Felix Fietkau
d2f1a01d9f add ubus_remove_object to libubus 2011-02-06 21:46:45 +01:00
Felix Fietkau
cb1feedb5e follow blob_get_int* -> blob_get_u* rename 2011-02-06 21:37:37 +01:00
Felix Fietkau
f8d55af76b rename publish to add_object 2011-02-06 21:33:03 +01:00
Felix Fietkau
2e83a5fab2 fix SIGINT handling 2011-02-06 02:19:54 +01:00
Felix Fietkau
ed4b742f3f implement code for receiving events 2011-02-05 23:23:44 +01:00