Commit b3221c12 authored by Olivier Crête's avatar Olivier Crête

udp-bsd: Set large enough sndbuf/rcvbuf on all platforms

parent 626dde0b
......@@ -86,6 +86,9 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
gboolean gret = FALSE;
GSocketAddress *gaddr;
struct UdpBsdSocketPrivate *priv;
gint sndbuf, rcvbuf;
GError *gerr = NULL;
const gint desiredbuf = 384 * 1024;;
if (addr != NULL) {
nice_address_copy_to_sockaddr(addr, &name.addr);
......@@ -115,6 +118,48 @@ nice_udp_bsd_socket_new (NiceAddress *addr)
return NULL;
}
if (!g_socket_get_option (gsock, SOL_SOCKET, SO_RCVBUF, &rcvbuf, &gerr)) {
g_warning ("Could not get rcvbuf size: %s", gerr->message);
g_clear_error (&gerr);
} else if (rcvbuf < desiredbuf) {
if (!g_socket_set_option (gsock, SOL_SOCKET, SO_RCVBUF, desiredbuf,
&gerr)) {
g_warning ("Could not set rcvbuf to %d: %s", desiredbuf, gerr->message);
g_clear_error (&gerr);
}
if (!g_socket_get_option (gsock, SOL_SOCKET, SO_RCVBUF, &rcvbuf, &gerr)) {
g_warning ("Could not get rcvbuf size: %s", gerr->message);
g_clear_error (&gerr);
} else if (rcvbuf < 128 * 1024)
g_warning ("rcvbuf is smaller than 100k");
else
g_warning ("rcvbuf set to %d", rcvbuf);
} else {
g_warning ("rcv was already good at %d", rcvbuf);
}
if (!g_socket_get_option (gsock, SOL_SOCKET, SO_SNDBUF, &sndbuf, &gerr)) {
g_warning ("Could not get sndbuf size: %s", gerr->message);
g_clear_error (&gerr);
} else if (sndbuf < desiredbuf) {
if (!g_socket_set_option (gsock, SOL_SOCKET, SO_SNDBUF, desiredbuf,
&gerr)) {
g_warning ("Could not set sndbuf to %d: %s", desiredbuf, gerr->message);
g_clear_error (&gerr);
}
if (!g_socket_get_option (gsock, SOL_SOCKET, SO_SNDBUF, &sndbuf, &gerr)) {
g_warning ("Could not get sndbuf size: %s", gerr->message);
g_clear_error (&gerr);
} else if (sndbuf < 128 * 1024)
g_warning ("sndbuf is smaller than 100k");
else
g_warning ("sndbuf set to %d", sndbuf);
} else {
g_warning ("snd was already good at %d", sndbuf);
}
/* GSocket: All socket file descriptors are set to be close-on-exec. */
g_socket_set_blocking (gsock, false);
gaddr = g_socket_address_new_from_native (&name.addr, sizeof (name));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment