You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
tcp: Use ff_connect_parallel for RFC 8305 style connecting
Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
@@ -108,30 +108,28 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
|
|||||||
|
|
||||||
cur_ai = ai;
|
cur_ai = ai;
|
||||||
|
|
||||||
restart:
|
if (s->listen) {
|
||||||
|
while (cur_ai && fd < 0) {
|
||||||
fd = ff_socket(cur_ai->ai_family,
|
fd = ff_socket(cur_ai->ai_family,
|
||||||
cur_ai->ai_socktype,
|
cur_ai->ai_socktype,
|
||||||
cur_ai->ai_protocol);
|
cur_ai->ai_protocol);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
ret = ff_neterrno();
|
ret = ff_neterrno();
|
||||||
goto fail;
|
cur_ai = cur_ai->ai_next;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (fd < 0)
|
||||||
|
goto fail1;
|
||||||
|
|
||||||
if (s->listen) {
|
|
||||||
if ((ret = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
|
if ((ret = ff_listen_bind(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
|
||||||
s->listen_timeout, h)) < 0) {
|
s->listen_timeout, h)) < 0) {
|
||||||
goto fail1;
|
goto fail1;
|
||||||
}
|
}
|
||||||
fd = ret;
|
fd = ret;
|
||||||
} else {
|
} else {
|
||||||
if ((ret = ff_listen_connect(fd, cur_ai->ai_addr, cur_ai->ai_addrlen,
|
ret = ff_connect_parallel(ai, s->timeout, 3, h, &fd, NULL, NULL);
|
||||||
s->timeout, h, !!cur_ai->ai_next)) < 0) {
|
if (ret < 0)
|
||||||
|
|
||||||
if (ret == AVERROR_EXIT)
|
|
||||||
goto fail1;
|
goto fail1;
|
||||||
else
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h->is_streamed = 1;
|
h->is_streamed = 1;
|
||||||
@@ -139,15 +137,6 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
|
|||||||
freeaddrinfo(ai);
|
freeaddrinfo(ai);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
if (cur_ai->ai_next) {
|
|
||||||
/* Retry with the next sockaddr */
|
|
||||||
cur_ai = cur_ai->ai_next;
|
|
||||||
if (fd >= 0)
|
|
||||||
closesocket(fd);
|
|
||||||
ret = 0;
|
|
||||||
goto restart;
|
|
||||||
}
|
|
||||||
fail1:
|
fail1:
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
closesocket(fd);
|
closesocket(fd);
|
||||||
|
Reference in New Issue
Block a user