Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwm4 <nfxjfg@googlemail.com>2018-01-02 19:05:03 +0300
committerwm4 <nfxjfg@googlemail.com>2018-01-04 17:07:55 +0300
commit8a108bdea06fac43af9f44b6d2538f357451167a (patch)
tree24428bb98451621940eb507a2b10173fe741a202 /libavformat/network.c
parent89bbf5c7ec18a3dff2e2505883a662d182ca6c3a (diff)
http: block while waiting for reconnecting
It makes no sense to return an error after the first reconnect, and then somehow resume the next time it's called. Usually this will lead to demuxer errors. Make reconnecting block instead, until it has either successfully reconnected, or given up. Also make the wait reasonably interruptible. Since there is no mechanism for this in the API, polling is the best we can do. This behaves roughly the same as other interruptible network functions in libavformat. (The original code would work if it returned AVERROR(EAGAIN) or so, which would make retry_transfer_wrapper() repeat the read call. But I think having an explicit loop for this is better anyway.) I also snuck in a fix for reconnect_at_eof. It has to check for AVERROR_EOF, not 0.
Diffstat (limited to 'libavformat/network.c')
-rw-r--r--libavformat/network.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/libavformat/network.c b/libavformat/network.c
index 6c3d9def3b..e9eb4b443a 100644
--- a/libavformat/network.c
+++ b/libavformat/network.c
@@ -103,6 +103,24 @@ int ff_network_wait_fd_timeout(int fd, int write, int64_t timeout, AVIOInterrupt
}
}
+int ff_network_sleep_interruptible(int64_t timeout, AVIOInterruptCB *int_cb)
+{
+ int64_t wait_start = av_gettime_relative();
+
+ while (1) {
+ int64_t time_left;
+
+ if (ff_check_interrupt(int_cb))
+ return AVERROR_EXIT;
+
+ time_left = timeout - (av_gettime_relative() - wait_start);
+ if (time_left <= 0)
+ return AVERROR(ETIMEDOUT);
+
+ av_usleep(FFMIN(time_left, POLLING_TIME * 1000));
+ }
+}
+
void ff_network_close(void)
{
#if HAVE_WINSOCK2_H