From 16edfb1a2bd0b7fa793618b8e5953e92e253a955 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Mon, 11 Sep 2023 06:24:20 +0000 Subject: Remove s6-tcpserver?d dependency on libs6 Signed-off-by: Laurent Bercot --- package/deps.mak | 4 ++-- src/conn-tools/deps-exe/s6-tcpserver4d | 1 - src/conn-tools/deps-exe/s6-tcpserver6d | 1 - src/conn-tools/s6-tcpserver4d.c | 14 +++++++++++--- src/conn-tools/s6-tcpserver6d.c | 14 +++++++++++--- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/package/deps.mak b/package/deps.mak index 26d3f5a..7c919da 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -128,13 +128,13 @@ s6-tcpserver4: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} s6-tcpserver4: src/conn-tools/s6-tcpserver4.o s6-tcpserver4-socketbinder: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} s6-tcpserver4-socketbinder: src/conn-tools/s6-tcpserver4-socketbinder.o -s6-tcpserver4d: EXTRA_LIBS := -ls6 -lskarnet ${SOCKET_LIB} +s6-tcpserver4d: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} s6-tcpserver4d: src/conn-tools/s6-tcpserver4d.o s6-tcpserver6: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} s6-tcpserver6: src/conn-tools/s6-tcpserver6.o s6-tcpserver6-socketbinder: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} s6-tcpserver6-socketbinder: src/conn-tools/s6-tcpserver6-socketbinder.o -s6-tcpserver6d: EXTRA_LIBS := -ls6 -lskarnet ${SOCKET_LIB} +s6-tcpserver6d: EXTRA_LIBS := -lskarnet ${SOCKET_LIB} s6-tcpserver6d: src/conn-tools/s6-tcpserver6d.o ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) libs6net.a.xyzzy: src/libs6net/s6net_ident_client.o src/libs6net/s6net_ident_reply_get.o src/libs6net/s6net_ident_reply_parse.o src/libs6net/s6net_ident_error.o diff --git a/src/conn-tools/deps-exe/s6-tcpserver4d b/src/conn-tools/deps-exe/s6-tcpserver4d index 062999f..19869b2 100644 --- a/src/conn-tools/deps-exe/s6-tcpserver4d +++ b/src/conn-tools/deps-exe/s6-tcpserver4d @@ -1,3 +1,2 @@ --ls6 -lskarnet ${SOCKET_LIB} diff --git a/src/conn-tools/deps-exe/s6-tcpserver6d b/src/conn-tools/deps-exe/s6-tcpserver6d index 062999f..19869b2 100644 --- a/src/conn-tools/deps-exe/s6-tcpserver6d +++ b/src/conn-tools/deps-exe/s6-tcpserver6d @@ -1,3 +1,2 @@ --ls6 -lskarnet ${SOCKET_LIB} diff --git a/src/conn-tools/s6-tcpserver4d.c b/src/conn-tools/s6-tcpserver4d.c index 8dd6614..5982816 100644 --- a/src/conn-tools/s6-tcpserver4d.c +++ b/src/conn-tools/s6-tcpserver4d.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -27,8 +28,6 @@ #include #include -#include - #define ABSOLUTE_MAXCONN 16384 #define USAGE "s6-tcpserver4d [ -v verbosity ] [ -1 ] [ -c maxconn ] [ -C localmaxconn ] prog..." @@ -257,7 +256,16 @@ static inline void new_connection (int s, uint32_t ip, uint16_t port, char const memcpy(fmt + m, "TCPCONNNUM=", 11) ; m += 11 ; m += uint_fmt(fmt + m, num) ; fmt[m++] = 0 ; - pid = s6_ucspiserver_spawn(s, argv, envp, envlen, fmt, m, 4) ; + { + cspawn_fileaction fa[2] = + { + [0] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = 0, [1] = s } } }, + [1] = { .type = CSPAWN_FA_COPY, .x = { .fd2 = { [0] = 1, [1] = 0 } } } + } ; + char const *newenvp[envlen + 5] ; + env_mergen(newenvp, envlen + 5, envp, envlen, fmt, m, 4) ; + pid = cspawn(argv[0], argv, newenvp, CSPAWN_FLAGS_SELFPIPE_FINISH, fa, 2) ; + } if (!pid) { if (verbosity) strerr_warnwu2sys("spawn ", argv[0]) ; diff --git a/src/conn-tools/s6-tcpserver6d.c b/src/conn-tools/s6-tcpserver6d.c index e3c66bd..4168d91 100644 --- a/src/conn-tools/s6-tcpserver6d.c +++ b/src/conn-tools/s6-tcpserver6d.c @@ -16,14 +16,13 @@ #include #include #include +#include #include #include #include #include #include -#include - #define ABSOLUTE_MAXCONN 16384 #define USAGE "s6-tcpserver6d [ -v verbosity ] [ -1 ] [ -c maxconn ] [ -C localmaxconn ] prog..." @@ -230,7 +229,16 @@ static inline void new_connection (int s, char const *ip, uint16_t port, char co memcpy(fmt + m, "TCPCONNNUM=", 11) ; m += 11 ; m += uint_fmt(fmt + m, num) ; fmt[m++] = 0 ; - pid = s6_ucspiserver_spawn(s, argv, envp, envlen, fmt, m, 4) ; + { + cspawn_fileaction fa[2] = + { + [0] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = 0, [1] = s } } }, + [1] = { .type = CSPAWN_FA_COPY, .x = { .fd2 = { [0] = 1, [1] = 0 } } } + } ; + char const *newenvp[envlen + 5] ; + env_mergen(newenvp, envlen + 5, envp, envlen, fmt, m, 4) ; + pid = cspawn(argv[0], argv, newenvp, CSPAWN_FLAGS_SELFPIPE_FINISH, fa, 2) ; + } if (!pid) { if (verbosity) strerr_warnwu2sys("spawn ", argv[0]) ; -- cgit v1.2.3