reduce size of send buffer

This commit is contained in:
Martin Pulec
2012-07-04 16:45:22 +02:00
parent 425e7d758e
commit 4fc16484da
6 changed files with 68 additions and 24 deletions

View File

@@ -1161,7 +1161,7 @@ then
AC_SUBST(RTDXT_COMPRESS_LIB_TARGET, "lib/ultragrid/vcompress_rtdxt.so.$video_compress_abi_version")
AC_SUBST(RTDXT_DECOMPRESS_LIB_TARGET, "lib/ultragrid/vdecompress_rtdxt.so.$video_decompress_abi_version")
LIB_TARGETS+=" $RTDXT_COMPRESS_LIB_TARGET $RTDXT_DECOMPRESS_LIB_TARGET"
LIB_OBJS+=" $RTDXT_COMMON_OBJ $RTDXT_COMMON_HEADERS $RTDXT_COMPRESS_OBJ $RTDXT_DECOMPRESS_OBJ"
LIB_OBJS+=" $RTDXT_COMMON_OBJ $RTDXT_COMPRESS_OBJ $RTDXT_DECOMPRESS_OBJ"
LIB_HEADERS="$RTDXT_COMMON_HEADERS"
fi

View File

@@ -424,10 +424,33 @@ static struct rtp **initialize_network(char *addrs, int recv_port_base, int send
RTCP_SDES_TOOL,
PACKAGE_STRING, strlen(PACKAGE_STRING));
#ifdef HAVE_MACOSX
rtp_set_recv_buf(devices[index], 5944320);
int size = 5944320;
#else
rtp_set_recv_buf(devices[index], 8*1024*1024);
int size = 8*1024*1024;
#endif
int ret = rtp_set_recv_buf(devices[index], size);
if(!ret) {
fprintf(stderr, "\n***\n"
"Unable to set buffer size to %d B.\n"
"Please set net.core.rmem_max value to %d or greater. (see also\n"
"https://www.sitola.cz/igrid/index.php/Setup_UltraGrid)\n"
#ifdef HAVE_MACOSX
"\tsysctl -w kern.ipc.maxsockbuf=%d\n"
"\tsysctl -w net.inet.udp.recvspace=%d\n"
#else
"\tsysctl -w net.core.rmem_max=%d\n"
#endif
"To make this persistent, add these options (key=value) to /etc/sysctl.conf\n"
"\n***\n\n",
size, size,
#ifdef HAVE_MACOSX
size * 4,
#endif /* HAVE_MACOSX */
size);
}
rtp_set_send_buf(devices[index], 1024 * 56);
pdb_add(participants, rtp_my_ssrc(devices[index]));
}

View File

@@ -458,7 +458,7 @@ int udp_set_recv_buf(socket_udp *s, int size)
if(SETSOCKOPT (s->fd, SOL_SOCKET, SO_RCVBUF, (const void *)&size,
sizeof(size)) != 0) {
perror("Unable to set socket buffer size");
goto error;
return FALSE;
}
opt_size = sizeof(opt);
@@ -469,32 +469,38 @@ int udp_set_recv_buf(socket_udp *s, int size)
}
if(opt < size) {
goto error;
return FALSE;
}
debug_msg("Socket buffer size set to %d B.\n", opt);
return TRUE;
}
error:
fprintf(stderr, "\n***\n"
"Unable to set buffer size to %d B.\n"
"Please set net.core.rmem_max value to %d or greater. (see also\n"
"https://www.sitola.cz/igrid/index.php/Setup_UltraGrid)\n"
#ifdef HAVE_MACOSX
"\tsysctl -w kern.ipc.maxsockbuf=%d\n"
"\tsysctl -w net.inet.udp.recvspace=%d\n"
#else
"\tsysctl -w net.core.rmem_max=%d\n"
#endif
"To make this persistent, add these options (key=value) to /etc/sysctl.conf\n"
"\n***\n\n",
size, size,
#ifdef HAVE_MACOSX
size * 4,
#endif /* HAVE_MACOSX */
size);
return FALSE;
int udp_set_send_buf(socket_udp *s, int size)
{
int opt = 0;
socklen_t opt_size;
if(SETSOCKOPT (s->fd, SOL_SOCKET, SO_SNDBUF, (const void *)&size,
sizeof(size)) != 0) {
perror("Unable to set socket buffer size");
return FALSE;
}
opt_size = sizeof(opt);
if(GETSOCKOPT (s->fd, SOL_SOCKET, SO_SNDBUF, (void *)&opt,
&opt_size) != 0) {
perror("Unable to get socket buffer size");
return FALSE;
}
if(opt < size) {
return FALSE;
}
debug_msg("Socket buffer size set to %d B.\n", opt);
return TRUE;
}
/*****************************************************************************/

View File

@@ -66,6 +66,7 @@ void udp_fd_set(socket_udp *s);
int udp_fd_isset(socket_udp *s);
int udp_set_recv_buf(socket_udp *s, int size);
int udp_set_send_buf(socket_udp *s, int size);
struct udp_fd_r {
fd_set rfd;

View File

@@ -3730,3 +3730,16 @@ int rtp_set_recv_buf(struct rtp *session, int bufsize)
return udp_set_recv_buf(session->rtp_socket, bufsize);
}
/**
* rtp_set_send_buf:
* Sets sender buffer size
* @session: The RTP Session.
*
* Returns: TRUE if succeeded
* FALSE otherwise
*/
int rtp_set_send_buf(struct rtp *session, int bufsize)
{
return udp_set_send_buf(session->rtp_socket, bufsize);
}

View File

@@ -265,4 +265,5 @@ uint8_t *rtp_get_userdata(struct rtp *session);
void rtp_set_recv_iov(struct rtp *session, struct msghdr *m);
int rtp_set_recv_buf(struct rtp *session, int bufsize);
int rtp_set_send_buf(struct rtp *session, int bufsize);
#endif /* __RTP_H__ */