summaryrefslogtreecommitdiff
path: root/sync.ha
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2023-11-08 01:57:37 +0100
committerJulian Hurst <ark@mansus.space>2023-11-08 01:57:37 +0100
commit50fb9c8d658cd175a2d810c47570ba0d939fccd4 (patch)
treea8f1a96097cb5e593dc0b13d8a5956dafddf3f38 /sync.ha
parent7b146ef6adbf764e54b8f896258e7372c31a253f (diff)
downloadmediasync-50fb9c8d658cd175a2d810c47570ba0d939fccd4.tar.gz
Close any open connections on SIGINT
Diffstat (limited to 'sync.ha')
-rw-r--r--sync.ha8
1 files changed, 8 insertions, 0 deletions
diff --git a/sync.ha b/sync.ha
index 85cc302..b407cbe 100644
--- a/sync.ha
+++ b/sync.ha
@@ -156,6 +156,14 @@ export fn main() void = {
};
if (pollfds[1].revents & poll::event::POLLIN != 0) {
signal::read(pollfds[1].fd)!;
+ for (let j = 2z; j < len(pollfds); j += 1) {
+ let s = pollfds[j].fd;
+ if (s != -1) {
+ log::printfln("Closing connection to client at index {} with fd {}", j, s: int);
+ net::close(s)!;
+ pollfds[j].fd = -1;
+ };
+ };
break;
};
for (let j = 2z; j < len(pollfds); j += 1) {