new package: libknot

* new subpackage: knot-utils
This commit is contained in:
Tee KOBAYASHI 2023-01-05 05:27:52 +09:00 committed by xtkoba
parent 5af6582097
commit 8a3390dff6
4 changed files with 122 additions and 0 deletions

13
packages/libknot/build.sh Normal file
View File

@ -0,0 +1,13 @@
TERMUX_PKG_HOMEPAGE=https://www.knot-dns.cz/
TERMUX_PKG_DESCRIPTION="Knot DNS libraries"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=3.2.4
TERMUX_PKG_SRCURL=https://secure.nic.cz/files/knot-dns/knot-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=299e8de918f9fc7ecbe625b41cb085e47cdda542612efbd51cd5ec60deb9dd13
TERMUX_PKG_DEPENDS="libgnutls, liblmdb"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--disable-daemon
--disable-modules
--enable-utilities
"

View File

@ -0,0 +1,11 @@
--- a/src/utils/common/resolv.c
+++ b/src/utils/common/resolv.c
@@ -24,7 +24,7 @@
#include "libknot/libknot.h"
#include "contrib/ucw/lists.h"
-#define RESOLV_FILE "/etc/resolv.conf"
+#define RESOLV_FILE "@TERMUX_PREFIX@/etc/resolv.conf"
srv_info_t* parse_nameserver(const char *str, const char *def_port)
{

View File

@ -0,0 +1,6 @@
TERMUX_SUBPKG_DESCRIPTION="Knot DNS utilities"
TERMUX_SUBPKG_INCLUDE="
bin/
share/man/man1/
"
TERMUX_SUBPKG_DEPENDS="libedit, libidn2, libnghttp2, resolv-conf"

View File

@ -0,0 +1,92 @@
--- a/src/contrib/conn_pool.c
+++ b/src/contrib/conn_pool.c
@@ -63,10 +63,26 @@
return fd;
}
+#ifdef __ANDROID__
+static void thread_signal_handler(int signum)
+{
+ pthread_exit(0);
+}
+#endif
+
static void *closing_thread(void *_arg)
{
conn_pool_t *pool = _arg;
+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_signal_handler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
+
while (true) {
knot_time_t now = knot_time(), next = 0;
knot_timediff_t timeout = conn_pool_timeout(pool, 0);
@@ -117,7 +133,11 @@
void conn_pool_deinit(conn_pool_t *pool)
{
if (pool != NULL) {
+#ifndef __ANDROID__
pthread_cancel(pool->closing_thread);
+#else
+ pthread_kill(pool->closing_thread, SIGUSR2);
+#endif
pthread_join(pool->closing_thread, NULL);
int fd;
--- a/src/knot/common/stats.c
+++ b/src/knot/common/stats.c
@@ -249,8 +249,24 @@
free(file_name);
}
+#ifdef __ANDROID__
+static void thread_signal_handler(int signum)
+{
+ pthread_exit(0);
+}
+#endif
+
static void *dumper(void *data)
{
+#ifdef __ANDROID__
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = thread_signal_handler;
+ sigaction(SIGUSR2, &actions, NULL);
+#endif
+
while (true) {
assert(stats.timer > 0);
sleep(stats.timer);
@@ -291,7 +307,11 @@
}
// Stop current dumping.
} else if (stats.active_dumper) {
+#ifndef __ANDROID__
pthread_cancel(stats.dumper);
+#else
+ pthread_kill(stats.dumper, SIGUSR2);
+#endif
pthread_join(stats.dumper, NULL);
stats.active_dumper = false;
}
@@ -300,7 +320,11 @@
void stats_deinit(void)
{
if (stats.active_dumper) {
+#ifndef __ANDROID__
pthread_cancel(stats.dumper);
+#else
+ pthread_kill(stats.dumper, SIGUSR2);
+#endif
pthread_join(stats.dumper, NULL);
}