From 47780a0167e6540614cde046fd6bbfbc33b95975 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 14 Nov 2023 13:38:36 +0100 Subject: [PATCH] rtp/net_udp: fix recv buf size not set [Win] Since 2023-09-20 (commit 97b956f5), UDP net buffers were not set, because the property was set on tx_fd, which is, howver, a different socket than rx_fd in Windows by default (not on other platforms). closes GH-358 --- src/rtp/net_udp.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/rtp/net_udp.c b/src/rtp/net_udp.c index e002b8b9b..59f8a1847 100644 --- a/src/rtp/net_udp.c +++ b/src/rtp/net_udp.c @@ -1450,17 +1450,19 @@ udp_get_recv_buf(socket_udp *s) static bool udp_set_buf(socket_udp *s, int sockopt, int size) { - int opt = 0; - socklen_t opt_size; - if (SETSOCKOPT(s->local->tx_fd, SOL_SOCKET, sockopt, (sockopt_t) &size, - sizeof(size)) != 0) { + assert(sockopt == SO_RCVBUF || sockopt == SO_SNDBUF); + const fd_t fd = + sockopt == SO_RCVBUF ? s->local->rx_fd : s->local->tx_fd; + if (SETSOCKOPT(fd, SOL_SOCKET, sockopt, (sockopt_t) &size, + sizeof(size)) != 0) { socket_error("Unable to set socket buffer size"); return false; } - opt_size = sizeof(opt); - if(GETSOCKOPT (s->local->tx_fd, SOL_SOCKET, sockopt, (sockopt_t)&opt, - &opt_size) != 0) { + int opt = 0; + socklen_t opt_size = sizeof opt; + if (GETSOCKOPT(fd, SOL_SOCKET, sockopt, (sockopt_t) &opt, &opt_size) != + 0) { socket_error("Unable to get socket buffer size"); return false; }