mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-24 13:56:33 +02:00
tcp: Use a different log message and level if there's more addresses to try
This lowers the level of warnings printed if trying to connect to a host name that provides both v6 and v4 addresses but the service only is available on the v4 address (often occurring for 'localhost', with servers that aren't v6-aware). Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
2a0ec47bd7
commit
abe5268c33
@ -240,7 +240,8 @@ int ff_listen_bind(int fd, const struct sockaddr *addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ff_listen_connect(int fd, const struct sockaddr *addr,
|
int ff_listen_connect(int fd, const struct sockaddr *addr,
|
||||||
socklen_t addrlen, int timeout, URLContext *h)
|
socklen_t addrlen, int timeout, URLContext *h,
|
||||||
|
int will_try_next)
|
||||||
{
|
{
|
||||||
struct pollfd p = {fd, POLLOUT, 0};
|
struct pollfd p = {fd, POLLOUT, 0};
|
||||||
int ret;
|
int ret;
|
||||||
@ -267,8 +268,12 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
|
|||||||
char errbuf[100];
|
char errbuf[100];
|
||||||
ret = AVERROR(ret);
|
ret = AVERROR(ret);
|
||||||
av_strerror(ret, errbuf, sizeof(errbuf));
|
av_strerror(ret, errbuf, sizeof(errbuf));
|
||||||
av_log(h, AV_LOG_ERROR,
|
if (will_try_next)
|
||||||
"Connection to %s failed: %s\n",
|
av_log(h, AV_LOG_WARNING,
|
||||||
|
"Connection to %s failed (%s), trying next address\n",
|
||||||
|
h->filename, errbuf);
|
||||||
|
else
|
||||||
|
av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n",
|
||||||
h->filename, errbuf);
|
h->filename, errbuf);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -238,11 +238,14 @@ int ff_listen_bind(int fd, const struct sockaddr *addr,
|
|||||||
* @param timeout Polling timeout in milliseconds.
|
* @param timeout Polling timeout in milliseconds.
|
||||||
* @param h URLContext providing interrupt check
|
* @param h URLContext providing interrupt check
|
||||||
* callback and logging context.
|
* callback and logging context.
|
||||||
|
* @param will_try_next Whether the caller will try to connect to another
|
||||||
|
* address for the same host name, affecting the form of
|
||||||
|
* logged errors.
|
||||||
* @return 0 on success, AVERROR on failure.
|
* @return 0 on success, AVERROR on failure.
|
||||||
*/
|
*/
|
||||||
int ff_listen_connect(int fd, const struct sockaddr *addr,
|
int ff_listen_connect(int fd, const struct sockaddr *addr,
|
||||||
socklen_t addrlen, int timeout,
|
socklen_t addrlen, int timeout,
|
||||||
URLContext *h);
|
URLContext *h, int will_try_next);
|
||||||
|
|
||||||
int ff_http_match_no_proxy(const char *no_proxy, const char *hostname);
|
int ff_http_match_no_proxy(const char *no_proxy, const char *hostname);
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
|
if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
|
||||||
timeout * 100, h)) < 0) {
|
timeout * 100, h, cur_ai->ai_next)) < 0) {
|
||||||
|
|
||||||
if (ret == AVERROR_EXIT)
|
if (ret == AVERROR_EXIT)
|
||||||
goto fail1;
|
goto fail1;
|
||||||
|
@ -83,7 +83,7 @@ static int unix_open(URLContext *h, const char *filename, int flags)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = ff_listen_connect(fd, (struct sockaddr *)&s->addr,
|
ret = ff_listen_connect(fd, (struct sockaddr *)&s->addr,
|
||||||
sizeof(s->addr), s->timeout, h);
|
sizeof(s->addr), s->timeout, h, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user