summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2019-07-18 12:57:43 -0700
committerRosen Penev <rosenp@gmail.com>2019-07-19 16:47:38 -0700
commitf3f42ff099e4657357fe58723dc5858fb6c7c329 (patch)
tree8c97b0366938d759a7d3553900f47086c2ba590d /libs
parent776e6d540990eabcd134d0bee8dd54695d9c53a7 (diff)
address: Replace ualarm with setitimer
ualarm has been deprecated and may not be available in the libc. Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'libs')
-rw-r--r--libs/luci-lib-nixio/src/address.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libs/luci-lib-nixio/src/address.c b/libs/luci-lib-nixio/src/address.c
index 8ab4fa89c..ed3a4a1c6 100644
--- a/libs/luci-lib-nixio/src/address.c
+++ b/libs/luci-lib-nixio/src/address.c
@@ -24,6 +24,7 @@
#ifdef __linux__
+#include <sys/time.h>
#include <signal.h>
#include <setjmp.h>
#include <unistd.h>
@@ -287,6 +288,7 @@ static int nixio_getnameinfo(lua_State *L) {
const char *family = luaL_optstring(L, 2, NULL);
#ifdef __linux__
+ const struct itimerval t = { {timeout * 1000 * 1000, 0} , {0, 0} };
struct sigaction sa_new, sa_old;
int timeout = luaL_optnumber(L, 3, 0);
if (timeout > 0 && timeout < 1000)
@@ -308,7 +310,7 @@ static int nixio_getnameinfo(lua_State *L) {
return 3;
}
- ualarm(timeout * 1000, 0);
+ setitimer(ITIMER_REAL, &t, NULL);
}
#endif
@@ -339,7 +341,7 @@ static int nixio_getnameinfo(lua_State *L) {
#ifdef __linux__
if (timeout > 0 && timeout < 1000)
{
- ualarm(0, 0);
+ alarm(0);
sigaction(SIGALRM, &sa_old, NULL);
}
#endif