tpws: move systemd notify deeper

This commit is contained in:
bol-van 2025-03-12 14:45:52 +03:00
parent cafbb17e70
commit 6493d55977
2 changed files with 15 additions and 14 deletions

View File

@ -30,10 +30,6 @@
#include <ifaddrs.h> #include <ifaddrs.h>
#endif #endif
#ifdef USE_SYSTEMD
#include <systemd/sd-daemon.h>
#endif
#include "tpws.h" #include "tpws.h"
#ifdef BSD #ifdef BSD
@ -1692,15 +1688,6 @@ static const char *bindll_s[] = { "unwanted","no","prefer","force" };
#define PRINT_VER printf("self-built version %s %s\n\n", __DATE__, __TIME__) #define PRINT_VER printf("self-built version %s %s\n\n", __DATE__, __TIME__)
#endif #endif
static void notify_ready(void)
{
#ifdef USE_SYSTEMD
int r = sd_notify(0, "READY=1");
if (r < 0)
DLOG_ERR("sd_notify: %s\n", strerror(-r));
#endif
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int i, listen_fd[MAX_BINDS], yes = 1, retval = 0, if_index, exit_v=EXIT_FAILURE; int i, listen_fd[MAX_BINDS], yes = 1, retval = 0, if_index, exit_v=EXIT_FAILURE;
@ -1978,7 +1965,6 @@ int main(int argc, char *argv[])
signal(SIGHUP, onhup); signal(SIGHUP, onhup);
signal(SIGUSR2, onusr2); signal(SIGUSR2, onusr2);
notify_ready();
retval = event_loop(listen_fd,params.binds_last+1); retval = event_loop(listen_fd,params.binds_last+1);
exit_v = retval < 0 ? EXIT_FAILURE : EXIT_SUCCESS; exit_v = retval < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
DLOG_CONDUP("Exiting\n"); DLOG_CONDUP("Exiting\n");

View File

@ -16,6 +16,10 @@
#include <fcntl.h> #include <fcntl.h>
#include <netdb.h> #include <netdb.h>
#ifdef USE_SYSTEMD
#include <systemd/sd-daemon.h>
#endif
#include "tpws.h" #include "tpws.h"
#include "tpws_conn.h" #include "tpws_conn.h"
#include "redirect.h" #include "redirect.h"
@ -25,6 +29,15 @@
#include "hostlist.h" #include "hostlist.h"
#include "linux_compat.h" #include "linux_compat.h"
static void notify_ready(void)
{
#ifdef USE_SYSTEMD
int r = sd_notify(0, "READY=1");
if (r < 0)
DLOG_ERR("sd_notify: %s\n", strerror(-r));
#endif
}
// keep separate legs counter. counting every time thousands of legs can consume cpu // keep separate legs counter. counting every time thousands of legs can consume cpu
static int legs_local, legs_remote; static int legs_local, legs_remote;
/* /*
@ -1542,6 +1555,8 @@ int event_loop(const int *listen_fd, size_t listen_fd_ct)
VPRINT("initialized multi threaded resolver with %d threads\n",resolver_thread_count()); VPRINT("initialized multi threaded resolver with %d threads\n",resolver_thread_count());
} }
notify_ready();
for(;;) for(;;)
{ {
ReloadCheck(); ReloadCheck();