new package: znc

This commit is contained in:
Tee KOBAYASHI 2022-03-15 13:44:40 +09:00 committed by xtkoba
parent 3ec084c976
commit 816ab0a967
2 changed files with 60 additions and 0 deletions

12
packages/znc/build.sh Normal file
View File

@ -0,0 +1,12 @@
TERMUX_PKG_HOMEPAGE=https://znc.in/
TERMUX_PKG_DESCRIPTION="An advanced IRC bouncer"
TERMUX_PKG_LICENSE="Apache-2.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.8.2
TERMUX_PKG_SRCURL=https://znc.in/releases/archive/znc-${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_SHA256=ff238aae3f2ae0e44e683c4aee17dc8e4fdd261ca9379d83b48a7d422488de0d
TERMUX_PKG_DEPENDS="libc++, libicu, libsasl, openssl, zlib"
TERMUX_PKG_FORCE_CMAKE=true
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-DWANT_I18N=OFF
"

View File

@ -0,0 +1,48 @@
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -18,6 +18,7 @@
#include <signal.h>
#include <time.h>
#include <thread>
+#include <atomic>
#if defined(HAVE_LIBSSL) && defined(HAVE_PTHREAD) && \
(!defined(OPENSSL_VERSION_NUMBER) || OPENSSL_VERSION_NUMBER < 0x10100004)
@@ -180,7 +181,7 @@
m_thread = std::thread([=]() { HandleSignals(pZNC); });
}
~CSignalHandler() {
- pthread_cancel(m_thread.native_handle());
+ m_thread_cancel.test_and_set();
m_thread.join();
}
@@ -203,6 +204,7 @@
};
void HandleSignals(CZNC* pZNC) {
+ m_thread_cancel.clear();
sigset_t signals;
sigemptyset(&signals);
sigaddset(&signals, SIGHUP);
@@ -216,11 +218,10 @@
pthread_sigmask(SIG_SETMASK, &signals, nullptr);
while (true) {
int sig;
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, nullptr);
+ if (m_thread_cancel.test_and_set()) pthread_exit(nullptr);
// This thread can be cancelled, but only during this function.
// Such cancel will be the only way to finish this thread.
if (sigwait(&signals, &sig) == -1) continue;
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, nullptr);
// TODO probably move switch() to CSignalHandlerMonitorFD?
switch (sig) {
case SIGHUP:
@@ -259,6 +260,7 @@
}
std::thread m_thread;
+ std::atomic_flag m_thread_cancel;
// pipe for waking up the main thread
int m_iPipe[2];