diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2024-04-23 20:29:26 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2024-04-23 20:29:26 +0000 |
commit | adf53fc275a1ea5959f4b3e55b290026009e973c (patch) | |
tree | 8360054c61f5d0be3ab028aebe0dd6790400a3aa /src/conn-tools/s6-tcpserverd.c | |
parent | e8eb657e23912ac34821e2fcadf6ea7dfed90fce (diff) | |
download | s6-networking-adf53fc275a1ea5959f4b3e55b290026009e973c.tar.xz |
Prepare for 2.7.0.3; fix s6-tcpserverd fd bug
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/conn-tools/s6-tcpserverd.c')
-rw-r--r-- | src/conn-tools/s6-tcpserverd.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/conn-tools/s6-tcpserverd.c b/src/conn-tools/s6-tcpserverd.c index e8c2c34..21946d9 100644 --- a/src/conn-tools/s6-tcpserverd.c +++ b/src/conn-tools/s6-tcpserverd.c @@ -263,8 +263,8 @@ static inline void new_connection (int s, char const *ip, uint16_t port, char co { 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 } } } + [0] = { .type = CSPAWN_FA_MOVE, .x = { .fd2 = { [0] = 1, [1] = s } } }, + [1] = { .type = CSPAWN_FA_COPY, .x = { .fd2 = { [0] = 0, [1] = 1 } } } } ; char const *newenvp[envlen + 7] ; env_mergen(newenvp, envlen + 7, envp, envlen, modifs, m, 6) ; @@ -322,12 +322,7 @@ int main (int argc, char const *const *argv) } if (coe(0) == -1 || ndelay_on(0) == -1) strerr_diefu1sys(111, "set socket flags") ; - if (flag1) - { - if (fcntl(1, F_GETFD) < 0) - strerr_dief1sys(100, "called with option -1 but stdout said") ; - } - else close(1) ; + if (!fd_ensure_open(1, 1)) strerr_diefu1sys(111, "sanitize stdout") ; if (!maxconn) maxconn = 1 ; if (maxconn > ABSOLUTE_MAXCONN) maxconn = ABSOLUTE_MAXCONN ; if (localmaxconn > maxconn) localmaxconn = maxconn ; @@ -402,8 +397,8 @@ int main (int argc, char const *const *argv) memcpy(fmtport, modifs + portpos, portlen) ; fmtport[portlen] = '\n' ; allwrite(1, fmtport, portlen + 1) ; - close(1) ; } + close(1) ; } while (cont) |