summaryrefslogtreecommitdiff
path: root/src/conn-tools/s6-tcpserver6d.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conn-tools/s6-tcpserver6d.c')
-rw-r--r--src/conn-tools/s6-tcpserver6d.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/conn-tools/s6-tcpserver6d.c b/src/conn-tools/s6-tcpserver6d.c
index 65e9133..e769ab1 100644
--- a/src/conn-tools/s6-tcpserver6d.c
+++ b/src/conn-tools/s6-tcpserver6d.c
@@ -8,9 +8,9 @@
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
+
#include <skalibs/gccattributes.h>
#include <skalibs/allreadwrite.h>
-#include <skalibs/uint16.h>
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
@@ -21,6 +21,7 @@
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
#include <skalibs/socket.h>
+#include <skalibs/exec.h>
#define ABSOLUTE_MAXCONN 1000
@@ -85,7 +86,7 @@ static inline unsigned int lookup_ip (char const *ip)
/* Logging */
-static void log_start (void)
+static inline void log_start (void)
{
strerr_warni1x("starting") ;
}
@@ -102,7 +103,7 @@ static void log_status (void)
strerr_warni3x("status: ", fmt, fmtmaxconn) ;
}
-static void log_deny (char const *ip, uint16_t port, unsigned int num)
+static inline void log_deny (char const *ip, uint16_t port, unsigned int num)
{
char fmtip[IP6_FMT] ;
char fmtport[UINT16_FMT] ;
@@ -113,7 +114,7 @@ static void log_deny (char const *ip, uint16_t port, unsigned int num)
strerr_warni7sys("deny ", fmtip, " port ", fmtport, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_accept (pid_t pid, char const *ip, uint16_t port, unsigned int num)
+static inline void log_accept (pid_t pid, char const *ip, uint16_t port, unsigned int num)
{
char fmtipport[IP6_FMT + UINT16_FMT + 6] ;
char fmtpid[PID_FMT] ;
@@ -128,7 +129,7 @@ static void log_accept (pid_t pid, char const *ip, uint16_t port, unsigned int n
strerr_warni7x("allow ", fmtipport, " pid ", fmtpid, " count ", fmtnum, fmtlocalmaxconn) ;
}
-static void log_close (pid_t pid, char const *ip, int w)
+static inline void log_close (pid_t pid, char const *ip, int w)
{
char fmtpid[PID_FMT] ;
char fmtip[IP6_FMT] = "?" ;
@@ -148,7 +149,7 @@ static void killthem (int sig)
for (; i < numconn ; i++) kill(pidip[i].pid, sig) ;
}
-static void wait_children (void)
+static inline void wait_children (void)
{
for (;;)
{
@@ -176,7 +177,7 @@ static void wait_children (void)
}
}
-static void handle_signals (void)
+static inline void handle_signals (void)
{
for (;;) switch (selfpipe_read())
{
@@ -222,8 +223,8 @@ static void handle_signals (void)
/* New connection handling */
-static void run_child (int, char const *, uint16_t, unsigned int, char const *const *, char const *const *) gccattr_noreturn ;
-static void run_child (int s, char const *ip, uint16_t port, unsigned int num, char const *const *argv, char const *const *envp)
+static inline void run_child (int, char const *, uint16_t, unsigned int, char const *const *) gccattr_noreturn ;
+static inline void run_child (int s, char const *ip, uint16_t port, unsigned int num, char const *const *argv)
{
char fmt[98] ;
size_t n = 0 ;
@@ -236,11 +237,10 @@ static void run_child (int s, char const *ip, uint16_t port, unsigned int num, c
n += uint16_fmt(fmt+n, port) ; fmt[n++] = 0 ;
memcpy(fmt+n, "TCPCONNNUM=", 11) ; n += 11 ;
n += uint_fmt(fmt+n, num) ; fmt[n++] = 0 ;
- pathexec_r(argv, envp, env_len(envp), fmt, n) ;
- strerr_dieexec(111, argv[0]) ;
+ xmexec_n(argv, fmt, n, 4) ;
}
-static void new_connection (int s, char const *ip, uint16_t port, char const *const *argv, char const *const *envp)
+static inline void new_connection (int s, char const *ip, uint16_t port, char const *const *argv)
{
unsigned int i = lookup_ip(ip) ;
unsigned int num = (i < iplen) ? ipnum[i].num : 0 ;
@@ -259,7 +259,7 @@ static void new_connection (int s, char const *ip, uint16_t port, char const *co
else if (!pid)
{
selfpipe_finish() ;
- run_child(s, ip, port, num+1, argv, envp) ;
+ run_child(s, ip, port, num+1, argv) ;
}
if (i < iplen) ipnum[i].num = num + 1 ;
@@ -278,7 +278,7 @@ static void new_connection (int s, char const *ip, uint16_t port, char const *co
}
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
iopause_fd x[2] = { { .events = IOPAUSE_READ }, { .fd = 0, .events = IOPAUSE_READ | IOPAUSE_EXCEPT } } ;
PROG = "s6-tcpserver6d" ;
@@ -379,7 +379,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
else
{
- new_connection(fd, ip, port, argv, envp) ;
+ new_connection(fd, ip, port, argv) ;
fd_close(fd) ;
}
}