From ab45d828cea484f72ec8573a29524894eb9b24ac Mon Sep 17 00:00:00 2001 From: Test_User Date: Wed, 19 Jun 2024 08:48:20 -0400 Subject: Mark futexes as private since it's all same-process, fix timeout on plaintext connections --- networks/plaintext.c | 9 +++++++++ networks/plaintext_buffered.c | 11 ++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'networks') diff --git a/networks/plaintext.c b/networks/plaintext.c index 4279f8c..7914b9e 100644 --- a/networks/plaintext.c +++ b/networks/plaintext.c @@ -143,6 +143,15 @@ int plaintext_accept(int listen_fd, void **handle, struct string *addr) { if (con_fd == -1) return -1; + { + struct timeval timeout = { + .tv_sec = PING_INTERVAL, + .tv_usec = 0, + }; + + setsockopt(con_fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); + } + addr->data = malloc(address_len); if (addr->data == 0 && address_len != 0) { close(con_fd); diff --git a/networks/plaintext_buffered.c b/networks/plaintext_buffered.c index 6f5016c..73a7803 100644 --- a/networks/plaintext_buffered.c +++ b/networks/plaintext_buffered.c @@ -114,7 +114,7 @@ void * plaintext_buffered_send_thread(void *handle) { ssize_t res; do { res = send(info->fd, &(info->buffer[read_buffer_index]), len, 0); - } while (res == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK || errno == ETIMEDOUT)); + } while (res == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)); if (res < 0) goto plaintext_buffered_send_thread_error; @@ -333,6 +333,15 @@ int plaintext_buffered_accept(int listen_fd, void **handle, struct string *addr) if (con_fd == -1) return -1; + { + struct timeval timeout = { + .tv_sec = PING_INTERVAL, + .tv_usec = 0, + }; + + setsockopt(con_fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); + } + struct plaintext_buffered_handle *plaintext_handle = malloc(sizeof(*plaintext_handle)); if (!plaintext_handle) goto plaintext_buffered_accept_close; -- cgit v1.2.3