[FFmpeg-cvslog] tcp: Use a different log message and level if there' s more addresses to try
Martin Storsjö
git at videolan.org
Tue Aug 6 17:57:50 CEST 2013
ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Mon Aug 5 19:44:20 2013 +0300| [abe5268c3328bf0e8fcfb7dc6e231b8920177c3a] | committer: Martin Storsjö
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 at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=abe5268c3328bf0e8fcfb7dc6e231b8920177c3a
---
libavformat/network.c | 13 +++++++++----
libavformat/network.h | 5 ++++-
libavformat/tcp.c | 2 +-
libavformat/unix.c | 2 +-
4 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/libavformat/network.c b/libavformat/network.c
index d8e6540..810a907 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -240,7 +240,8 @@ int ff_listen_bind(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};
int ret;
@@ -267,9 +268,13 @@ int ff_listen_connect(int fd, const struct sockaddr *addr,
char errbuf[100];
ret = AVERROR(ret);
av_strerror(ret, errbuf, sizeof(errbuf));
- av_log(h, AV_LOG_ERROR,
- "Connection to %s failed: %s\n",
- h->filename, errbuf);
+ if (will_try_next)
+ 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);
}
default:
return ret;
diff --git a/libavformat/network.h b/libavformat/network.h
index 99d96af..85b8f6d 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -238,11 +238,14 @@ int ff_listen_bind(int fd, const struct sockaddr *addr,
* @param timeout Polling timeout in milliseconds.
* @param h URLContext providing interrupt check
* 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.
*/
int ff_listen_connect(int fd, const struct sockaddr *addr,
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);
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 68bf9f1..39065aa 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -100,7 +100,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
}
} else {
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)
goto fail1;
diff --git a/libavformat/unix.c b/libavformat/unix.c
index 95552a9..ab57c68 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -83,7 +83,7 @@ static int unix_open(URLContext *h, const char *filename, int flags)
}
} else {
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)
goto fail;
}
More information about the ffmpeg-cvslog
mailing list