[FFmpeg-devel] [PATCH 1/1] avformat/tcp: support timeout for getaddrinfo For fixing stucking when resolving addrinfo

XinZheng Zhang zhangxzheng at gmail.com
Wed Jun 1 06:03:32 CEST 2016

On Tue, May 31, 2016 at 9:33 PM, Hendrik Leppkes <h.leppkes at gmail.com> wrote:
> On Tue, May 31, 2016 at 2:58 PM, Xinzheng Zhang <zhangxzheng at gmail.com> wrote:
> > ---
> >  libavformat/tcp.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 215 insertions(+)
> >
> This whole patch looks extremely complicated and long for something
> hidden behind a tiny option not saying much.
> Maybe you should start by elaborating in detail what you are trying to
> fix, how you are fixing it, and why you choose this approach and not
> any others that may appear simpler.

For some ugly network conditions(Eg.Mobile device in a WiFi network,
but offline from internet), getaddrinfo() could block tcp_open() for a
long time,
neither timeout nor interrupt callback can save us.

There are serveral way to fix this issue
AFAIK. We can use `getaddrinfo_a` on some linux platform
But, it doesn't work on other platforms.

Besides, we can put this task into a background thread,
and detach from it when we want to cancel the task,
or it is timed out. But unfortunately,
there are no global thread pool or other background facility
to host such detached tasks in ffmpeg

More information about the ffmpeg-devel mailing list