Skip to content
Snippets Groups Projects
Commit 0ed0af59 authored by Jun Zhao's avatar Jun Zhao Committed by Jun Zhao
Browse files

lavf/tcp: check return value of setsockopt.


when setsockopt fail, use ff_log_net_error to dump the string
describing for error number.

Signed-off-by: default avatarJun Zhao <mypopydev@gmail.com>
parent 0a8ff1d8
No related branches found
No related tags found
No related merge requests found
...@@ -151,17 +151,25 @@ static int tcp_open(URLContext *h, const char *uri, int flags) ...@@ -151,17 +151,25 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
/* Set the socket's send or receive buffer sizes, if specified. /* Set the socket's send or receive buffer sizes, if specified.
If unspecified or setting fails, system default is used. */ If unspecified or setting fails, system default is used. */
if (s->recv_buffer_size > 0) { if (s->recv_buffer_size > 0) {
setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &s->recv_buffer_size, sizeof (s->recv_buffer_size)); if (setsockopt (fd, SOL_SOCKET, SO_RCVBUF, &s->recv_buffer_size, sizeof (s->recv_buffer_size))) {
ff_log_net_error(h, AV_LOG_WARNING, "setsockopt(SO_RCVBUF)");
}
} }
if (s->send_buffer_size > 0) { if (s->send_buffer_size > 0) {
setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &s->send_buffer_size, sizeof (s->send_buffer_size)); if (setsockopt (fd, SOL_SOCKET, SO_SNDBUF, &s->send_buffer_size, sizeof (s->send_buffer_size))) {
ff_log_net_error(h, AV_LOG_WARNING, "setsockopt(SO_SNDBUF)");
}
} }
if (s->tcp_nodelay > 0) { if (s->tcp_nodelay > 0) {
setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &s->tcp_nodelay, sizeof (s->tcp_nodelay)); if (setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &s->tcp_nodelay, sizeof (s->tcp_nodelay))) {
ff_log_net_error(h, AV_LOG_WARNING, "setsockopt(TCP_NODELAY)");
}
} }
#if !HAVE_WINSOCK2_H #if !HAVE_WINSOCK2_H
if (s->tcp_mss > 0) { if (s->tcp_mss > 0) {
setsockopt (fd, IPPROTO_TCP, TCP_MAXSEG, &s->tcp_mss, sizeof (s->tcp_mss)); if (setsockopt (fd, IPPROTO_TCP, TCP_MAXSEG, &s->tcp_mss, sizeof (s->tcp_mss))) {
ff_log_net_error(h, AV_LOG_WARNING, "setsockopt(TCP_MAXSEG)");
}
} }
#endif /* !HAVE_WINSOCK2_H */ #endif /* !HAVE_WINSOCK2_H */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment