summaryrefslogtreecommitdiff
path: root/ot_socket.c
diff options
context:
space:
mode:
authorDirk Engling <erdgeist@erdgeist.org>2026-10-28 23:31:07 +0100
committerDirk Engling <erdgeist@erdgeist.org>2026-10-28 23:31:07 +0100
commit772873104658182a5b76f5c0eed76047c62c6651 (patch)
tree431ba9c063fab10b4356cd8c7e63c9d2e957e2d9 /ot_socket.c
parentdd0ad26ea9824b75accced2b56328cbb222c4c6d (diff)
With more workers blockingly waiting on udp sockets, we need to keep track of all sockets to shut them down on exit
Diffstat (limited to 'ot_socket.c')
-rw-r--r--ot_socket.c7
1 files changed, 7 insertions, 0 deletions
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 @@
9#include <netinet/in.h> 9#include <netinet/in.h>
10#include <string.h> 10#include <string.h>
11#include <sys/socket.h> 11#include <sys/socket.h>
12#include <sys/time.h>
12#include <unistd.h> 13#include <unistd.h>
13 14
14/* Opentracker */ 15/* Opentracker */
@@ -48,6 +49,12 @@ int socket_set_blocking(int s, int blocking) {
48 return fcntl(s, F_SETFL, blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK)); 49 return fcntl(s, F_SETFL, blocking ? (flags & ~O_NONBLOCK) : (flags | O_NONBLOCK));
49} 50}
50 51
52int socket_set_timeout(int s, int seconds) {
53 struct timeval patience = {seconds, 0};
54
55 return setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &patience, sizeof(patience));
56}
57
51static int set_nonblocking(int s) { return socket_set_blocking(s, 0); } 58static int set_nonblocking(int s) { return socket_set_blocking(s, 0); }
52 59
53/* Close without letting the failure we are about to report be overwritten */ 60/* Close without letting the failure we are about to report be overwritten */