Skip to content

Commit

Permalink
rtp/net_udp: fix recv buf size not set [Win]
Browse files Browse the repository at this point in the history
Since 2023-09-20 (commit 97b956f), 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
  • Loading branch information
MartinPulec committed Nov 14, 2023
1 parent 7350c5d commit 47780a0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/rtp/net_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 47780a0

Please sign in to comment.