Commit graph

224 commits

Author SHA1 Message Date
Felix Fietkau
04f194aa8a uloop: fix deleting pending fd events on uloop_fd_del
When a fd gets deleted internally due to errors, fd->registered gets set
to false before events are moved to the staging array.
This leads to pending events not getting cleared properly when the fd
user finally calls uloop_fd_del.
Fix this by moving the check down and always checking for pending
events.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-08-01 00:01:40 +02:00
Felix Fietkau
ef9b6b92df blob/blobmsg: add null pointer checks to the *_for_each_attr functions, fix formatting
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-07-29 14:44:11 +02:00
Helmut Schaa
510e4956e5 uloop: Fix incorrect timeout
uloop timeouts are calculated based on a time value that was fetched
before any callbacks were executed. Hence, the next timeout is off by
the time the callback execution took which can lead to strange side
effects.

Fix this by calculating the next timeout based on a fresh time value.

Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2013-07-24 15:01:19 +02:00
John Crispin
11e8afea0f runqueue should cal the complete handler from more places
Signed-off-by: John Crispin <blogic@openwrt.org>
2013-07-02 18:33:46 +02:00
Felix Fietkau
316e3fb6c2 safe_list: add missing null pointer check in safe_list_del()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-28 13:05:06 +02:00
Felix Fietkau
c434230a76 ustream: return NULL in ustream_get_read_buf if there's a buffer, but no data
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-21 19:53:09 +02:00
Felix Fietkau
6f192a6fb0 blobmsg_json: do not corrupt UTF-8 strings
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-21 17:19:37 +02:00
Felix Fietkau
7c5d2b3081 blobmsg_json: fix \u escaping for control characters
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-21 17:06:34 +02:00
Felix Fietkau
b9ebdbcc64 uloop: fix corner cases with recursive uloop_run calls
With multiple recursive calls to uloop_run, the callback for the same fd
can be run multiple times from different levels in the stack.
Prevent this by tracking the stack of uloop_fd callbacks and buffering new
incoming events for fds already on the stack.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
35cee2c206 uloop: fix event flags processing on mac os x
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
e386259632 libubox: make uloop_fd::flags generic
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 12:05:09 +02:00
Felix Fietkau
cd5238b500 uloop: fix edge trigger handling on mac os x
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-18 11:02:20 +02:00
Felix Fietkau
ae40b66130 uloop: rework event processing, fix use-after-free issues
Recursive calls to uloop_run() need to process already fetched events
first, before running kqueue/epoll to get more.

The state of cur_fd/cur_nfds and the event list needs to be maintained
properly to prevent accidental running of events pointing at deleted
uloop_fd structs.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-11 12:55:21 +02:00
Felix Fietkau
e5032709b2 utils: add bitfield inline ops
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-06-10 13:37:14 +02:00
Felix Fietkau
2851ce7edb ustream: only report stream eof once via state_change callback
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-31 11:18:26 +02:00
Felix Fietkau
70e7c09bcb ustream: only report a write error once via state_change callback
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-31 11:17:02 +02:00
Felix Fietkau
54a0b49326 blobmsg_json: add blobmsg_add_json_from_file
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-29 12:14:48 +02:00
Felix Fietkau
c4b79e4b54 runqueue: move completion handler from runqueue_process to runqueue_task to make it more generic
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:27:45 +02:00
Felix Fietkau
92fdad5448 runqueue: fix include path
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:15:05 +02:00
Felix Fietkau
cb6c1718e7 runqueue: add a simple task queueing/completion tracking implementation
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:10:00 +02:00
Felix Fietkau
3ceb819690 ustream-example: fix container_of type errors
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-05-09 01:06:55 +02:00
Helmut Schaa
ecee1a3bea libubox: Allow to build against libjson-c > 0.9
Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com>
2013-05-07 15:53:36 +02:00
Felix Fietkau
dcf93f3322 safe_list: add safe_list_empty()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-04-15 15:53:57 +02:00
Felix Fietkau
ee3e7a6f9f safe_list: fix typo
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-04-15 15:39:09 +02:00
Felix Fietkau
009b4d574e list.h: implement type safety for container_of()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-18 05:55:00 +01:00
Felix Fietkau
cdb9f71971 avl: fix type handling in container_of uses
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-18 05:53:44 +01:00
Felix Fietkau
7c11f6e913 safe_list: add a new linked list variant
Use this linked list implementation as a replacement for list.h if you
want to allow deleting arbitrary list entries from within one or more
recursive iterator calling context

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-18 05:47:53 +01:00
Felix Fietkau
00a833c5b6 jshn: add support for the double datatype
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-17 00:50:03 +01:00
Thomas Gstädtner
49e6e062b8 add pkgconfig support for json-c
this includes a fallback for legacy support
2013-03-05 10:44:48 +01:00
Felix Fietkau
b2010c706c json_script: do not rely on global includes for other libubox header files
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-02 16:21:11 +01:00
Felix Fietkau
38ea521911 add json_script, a minimalistic JSON based script interpreter
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-28 21:50:55 +01:00
Felix Fietkau
af2f52a37b blobmsg: implement blobmsg_printf and blobmsg_vprintf
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-17 16:42:12 +01:00
Felix Fietkau
bd47d85d38 utils: make le16 endian conversion functions work with arguments that have side effects
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-14 23:39:57 +01:00
Felix Fietkau
fcd5ba8fbd utils.h: make 16-bit little endian conversion robust against pointer subtraction arguments
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-14 22:02:56 +01:00
Felix Fietkau
d01922625d utils: add little-endian swap helpers
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-13 12:35:19 +01:00
Felix Fietkau
e5a40544ec utils: prefer using gccs builtin swapping functions which support constant folding
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-11 22:08:07 +01:00
Felix Fietkau
5ad190fccf utils: move endian swap helpers and __packed definition to utils.h
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-11 21:46:41 +01:00
Felix Fietkau
4ab499899c blobmsg: add blobmsg_realloc_string_buffer()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-10 20:43:51 +01:00
Felix Fietkau
b786f85267 blob: add blob_buf_grow()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-10 20:43:33 +01:00
Felix Fietkau
9a3519536b blobmsg_json: prefer to link against libjson-c over libjson (the new library name in git versions of json-c)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-10 15:32:45 +01:00
Felix Fietkau
95fde87029 ustream: another fix for ustream_read_buf_full() with split read buffers
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-31 18:10:52 +01:00
Felix Fietkau
f83b6548c7 ustream-fd: do not loop back into the callback from ustream_fd_set_uloop
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-31 17:08:40 +01:00
Felix Fietkau
bc6a230b50 ustream: set the right EOF flag
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-31 17:02:49 +01:00
Felix Fietkau
766ff98050 uloop: remove file descriptors if neither read nor write notification is requested
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-31 16:43:08 +01:00
Felix Fietkau
f24b6294c2 ustream-fd: only use read() == 0 as eof indication, and issue a state change notification when that happens
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-30 17:48:55 +01:00
Felix Fietkau
e72b65c899 ustream: fix ustream_read_buf_full() for multiple read buffers
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-30 16:52:32 +01:00
Felix Fietkau
0bc317aa4d blobmsg_json: fix buffer growing on blobmsg json formatting 2013-01-29 23:07:10 +01:00
Jo-Philipp Wich
8b0d933154 uloop: rename uloop_timeout_pending() to uloop_timeout_remaining() 2013-01-23 19:33:12 +01:00
Jo-Philipp Wich
77984bd24d uloop: add uloop_timeout_pending() function to determine the remaining time of an active timeout 2013-01-23 19:32:45 +01:00
Felix Fietkau
e009fd8c82 build: remove install prefix override
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-01-23 15:22:29 +01:00