aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-05-26 16:47:45 -0400
committerTest_User <hax@andrewyu.org>2024-05-26 16:47:56 -0400
commit462f11de02e2cde6c4c196acf9c3dfa8c6d75f3d (patch)
tree86c8101e137700493f24ab12d152e2635fee4293
parent5e819c46cdf88ec09125cb593757d1203245a8b7 (diff)
downloadcoupserv-462f11de02e2cde6c4c196acf9c3dfa8c6d75f3d.tar.gz
coupserv-462f11de02e2cde6c4c196acf9c3dfa8c6d75f3d.zip
Writing on stale fds is a bad idea
-rw-r--r--client_network.c2
-rw-r--r--main.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/client_network.c b/client_network.c
index 93ad1d9..1a7d60c 100644
--- a/client_network.c
+++ b/client_network.c
@@ -569,7 +569,7 @@ int initclientnetwork(void) {
#if LOGALL
ssize_t SENDCLIENT(struct string msg) {
- if (msg.len == 0)
+ if (msg.len == 0 || client_fd == -1)
return 0;
static char printprefix = 1;
diff --git a/main.c b/main.c
index 50126a8..f720b3c 100644
--- a/main.c
+++ b/main.c
@@ -233,6 +233,7 @@ void *client_loop(void *ign) {
}
close(client_fd);
+ client_fd = -1;
free(full_msg.data);
listen(client_listen_fd, 1);
}