You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avformat/libsrt: fix checking connection result in non-blocking mode
After f8990c5f41
we properly set non-blocking
mode which makes the connect() call return always 0 even if no connection can
be established.
Fix this by always doing a poll after calling connect(). Also there was some
leftover copy paste code which checks for various errors which are simply not
possible with SRT.
Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
@@ -250,34 +250,19 @@ static int libsrt_listen_connect(int eid, int fd, const struct sockaddr *addr, s
|
|||||||
if (libsrt_socket_nonblock(fd, 1) < 0)
|
if (libsrt_socket_nonblock(fd, 1) < 0)
|
||||||
av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
|
av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n");
|
||||||
|
|
||||||
while ((ret = srt_connect(fd, addr, addrlen))) {
|
ret = srt_connect(fd, addr, addrlen);
|
||||||
ret = libsrt_neterrno(h);
|
if (ret < 0)
|
||||||
switch (ret) {
|
return libsrt_neterrno(h);
|
||||||
case AVERROR(EINTR):
|
|
||||||
if (ff_check_interrupt(&h->interrupt_callback))
|
ret = libsrt_network_wait_fd_timeout(h, eid, fd, 1, timeout, &h->interrupt_callback);
|
||||||
return AVERROR_EXIT;
|
if (ret < 0) {
|
||||||
continue;
|
if (will_try_next) {
|
||||||
case AVERROR(EINPROGRESS):
|
av_log(h, AV_LOG_WARNING,
|
||||||
case AVERROR(EAGAIN):
|
"Connection to %s failed (%s), trying next address\n",
|
||||||
ret = libsrt_network_wait_fd_timeout(h, eid, fd, 1, timeout, &h->interrupt_callback);
|
h->filename, av_err2str(ret));
|
||||||
if (ret < 0)
|
} else {
|
||||||
return ret;
|
av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n",
|
||||||
ret = srt_getlasterror(NULL);
|
h->filename, av_err2str(ret));
|
||||||
srt_clearlasterror();
|
|
||||||
if (ret != 0) {
|
|
||||||
char buf[128];
|
|
||||||
ret = AVERROR(ret);
|
|
||||||
av_strerror(ret, buf, sizeof(buf));
|
|
||||||
if (will_try_next)
|
|
||||||
av_log(h, AV_LOG_WARNING,
|
|
||||||
"Connection to %s failed (%s), trying next address\n",
|
|
||||||
h->filename, buf);
|
|
||||||
else
|
|
||||||
av_log(h, AV_LOG_ERROR, "Connection to %s failed: %s\n",
|
|
||||||
h->filename, buf);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user