This function was only ever called straight after
accept_incoming_connections, so simply make
accept_incoming_connections free the sockets at quit time.
---
server/internal.h | 2 --
server/main.c | 2 --
server/sockets.c | 16 ++++++----------
3 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/server/internal.h b/server/internal.h
index b28b1c8..4638727 100644
--- a/server/internal.h
+++ b/server/internal.h
@@ -474,8 +474,6 @@ extern int *bind_vsock (size_t *)
__attribute__((__nonnull__ (1)));
extern void accept_incoming_connections (int *socks, size_t nr_socks)
__attribute__((__nonnull__ (1)));
-extern void free_listening_sockets (int *socks, size_t nr_socks)
- __attribute__((__nonnull__ (1)));
/* threadlocal.c */
extern void threadlocal_init (void);
diff --git a/server/main.c b/server/main.c
index dcfdbde..8ff8e79 100644
--- a/server/main.c
+++ b/server/main.c
@@ -885,7 +885,6 @@ start_serving (void)
change_user ();
write_pidfile ();
accept_incoming_connections (socks, nr_socks);
- free_listening_sockets (socks, nr_socks); /* also closes them */
return;
}
@@ -913,7 +912,6 @@ start_serving (void)
fork_into_background ();
write_pidfile ();
accept_incoming_connections (socks, nr_socks);
- free_listening_sockets (socks, nr_socks);
}
static void
diff --git a/server/sockets.c b/server/sockets.c
index 119cb99..11bab6c 100644
--- a/server/sockets.c
+++ b/server/sockets.c
@@ -322,16 +322,6 @@ bind_vsock (size_t *nr_socks)
#endif
}
-void
-free_listening_sockets (int *socks, size_t nr_socks)
-{
- size_t i;
-
- for (i = 0; i < nr_socks; ++i)
- close (socks[i]);
- free (socks);
-}
-
struct thread_data {
int sock;
size_t instance_num;
@@ -476,6 +466,12 @@ check_sockets_and_quit_fd (int *socks, size_t nr_socks)
void
accept_incoming_connections (int *socks, size_t nr_socks)
{
+ size_t i;
+
while (!quit)
check_sockets_and_quit_fd (socks, nr_socks);
+
+ for (i = 0; i < nr_socks; ++i)
+ close (socks[i]);
+ free (socks);
}
--
2.23.0