Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lua
AgeCommit message (Collapse)Author
2023-11-02uloop: add support for user defined signal handlersJo-Philipp Wich
Reuse and extend the existing signal waker pipe mechanism to add user defined signal handling functionality to uloop. This commit introduces two new api functions `uloop_signal_add()` and `uloop_signal_remove()` along with a new structure type `uloop_signal` to allow adding and removing arbitrary signal handlers. Registered signal handlers are maintained in a linked list and matched by their signo member value which allows registering multiple handlers for the same signal numbers. Upon registering a new signal handler, the existing handler is saved in the `uloop_signal` structure. When removing the user defined signal handler, the original behavior is restored. The Lua binding has been updated as well to support the new signal handler mechanism. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2023-11-02uloop: add support for interval timersJo-Philipp Wich
So far, the only way to implement periodic interval timers was to use one-shot uloop_timeout timers which are rearmed within their completion callback immediately on expiration. While simple, this approach is not very precise and interval lengths will slowly drift over time, due to callback execution overhead, scheduling granularity etc. In order to make uloop provide stable and precise interval timer capabilities, this commit introduces a new `uloop_interval` structure along with the new related `uloop_interval_set()`, `uloop_interval_cancel()` and `uloop_interval_remaining()` api functions. Periodic timers are implemented using the timerfd facility an Linux and kqueue EVFILT_TIMER events on macOS/BSD. The Lua binding has been updated to include support for the new timer type as well. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2021-11-04lua/uloop: use uloop_timeout_remaining64Stijn Tintel
We will deprecate uloop_timeout_remaining soon. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be> Acked-by: Jo-Philipp Wich <jo@mein.io> Acked-by: John Crispin <john@phrozen.org>
2020-07-11lua/uloop: fd_add: use absolute indices for argumentsKarl Palsson
Instead of having to adjust the index repeatedly as the stack is manipulated, use absolute addressing for the function arguments, so they stay the same throughout the call. Zero functional change, just subjectively easier to follow variables. Signed-off-by: Karl Palsson <karlp@etactica.com>
2020-07-11lua/uloop: make get_sock_fd capable of absolute addressesKarl Palsson
The original code required the use of relative addresses into the lua stack. It should accept either. Signed-off-by: Karl Palsson <karlp@etactica.com>
2020-07-11lua/uloop: fd_add() better args checkingKarl Palsson
Actually check for flags being valid, instead of simply ignoring the call if flags was zero. Use standard lua checks for the function argument, so you can get a normal "argument #2 was invalid, expected function, got xxx" instead of the vague, "invalid arg list" Signed-off-by: Karl Palsson <karlp@etactica.com>
2016-12-13libubox: allow reading out the pid of uloop process in luaFlorian Eckert
Add Lua method to get the forked pid of a uloop process Signed-off-by: Florian Eckert <Eckert.Florian@googlemail.com>
2016-12-05libubox: allow reading out the remaining time of a uloop timer in LuaStijn Cleynhens
Add Lua method to the uloop wrapper to allow reading out the remaining time of a uloop timer Signed-off-by: Stijn Cleynhens <stijncleynhens@gmail.com>
2016-06-26Fix various memory management issuesMatthias Schiffer
Consistently handle allocation failures. Some functions are changed to return bool or int instead of void to allow returning an error. Also fix a buffer size miscalculation in lua/uloop and use _exit() instead of exit() on errors after forking. Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2016-01-15lua: add gc/delete support for processesFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2016-01-15lua: create a common function for userdata with gcFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-22libubox: lua: use pkg-config built in module to search for alternativesKarl Palsson
Different distributions have different names for the lua 5.1 package. Use cmake's built in pkg-config support to search for the first one, rather than running it explicitly and searching for a single version. Signed-off-by: Karl Palsson <karlp@remake.is>
2014-12-11lua: do not hardcode /opt/local/include for Apple.Yousong Zhou
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-07-27lua/uloop: 'end' is the keyword of Lua, use 'cancel' replace it.xfguo@credosemi.com
Signed-off-by: Xiongfei Guo <xfguo@credosemi.com>
2014-06-24Fix bug of GC in fd and timeout objects for lua binding.Xiongfei Guo
fd and timeout lua object has a __gc method in its metatable. After the object is freed and the another new object use the same reference in __uloop_cb and __uloop_fds, the new object will be freed by the old __gc of the old object when garbag collecting. Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24Fix bug of unref resources in Lua binding; fd method delete -> cancel.Xiongfei Guo
Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24Support delete a fd event.Xiongfei Guo
When you call the fd_add, it will return an object with `delete` method. So you can delete that event if you want. Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24Added fd_add method for uloop lua binding.Xiongfei Guo
Use uloop.fd_add like this: local socket = require "socket" udp = socket.udp() uloop.fd_add( udp, -- socket function( -- callback function ufd, -- socket object when register the fd events -- uloop events. eg. uloop.ULOOP_READ . ) local words, msg_or_ip, port_or_nil = ufd:receivefrom() print('Recv UDP packet from '..msg_or_ip..':'..port_or_nil..' : '..words) end, uloop.ULOOP_READ -- event you want to listen ) The `examples/uloop-example.lua` show an example of this work. Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2014-06-24Fix stack overflow bug of uloop lua binding.Xiongfei Guo
The static variable `state` in `lua/uloop.c` should be clean after every callback. Signed-off-by: Xiongfei(Alex) Guo <xfguo@credosemi.com>
2012-10-22add declarations for lua{open,close}_uloop to avoid warningsFelix Fietkau
2012-10-04lua: use relative paths for includes instead of system-wideFelix Fietkau
2012-09-29rename proc_cb to ul_process_cbJohn Crispin
Signed-off-by: John Crispin <blogic@openwrt.org>
2012-09-27add lua binding for uloop (written by John Crispin)Felix Fietkau