From 772873104658182a5b76f5c0eed76047c62c6651 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Wed, 28 Oct 2026 23:31:07 +0100 Subject: With more workers blockingly waiting on udp sockets, we need to keep track of all sockets to shut them down on exit --- ot_socket.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'ot_socket.c') diff --git a/ot_socket.c b/ot_socket.c index 158459f..c73738c 100644 --- a/ot_socket.c +++ b/ot_socket.c @@ -9,6 +9,7 @@ #include #include #include +#include #include /* Opentracker */ @@ -48,6 +49,12 @@ int socket_set_blocking(int s, int blocking) { return fcntl(s, F_SETFL, blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK)); } +int socket_set_timeout(int s, int seconds) { + struct timeval patience = {seconds, 0}; + + return setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &patience, sizeof(patience)); +} + static int set_nonblocking(int s) { return socket_set_blocking(s, 0); } /* Close without letting the failure we are about to report be overwritten */ -- cgit v1.3