[FFmpeg-devel] [PATCH] avformat/unix: properly handling timeout at reading

Bodecs Bela bodecsb at vivanet.hu
Tue Mar 20 21:42:40 EET 2018


Dear All,

avio rw_timeout handling in retry_transfer_wrapper() is based on returning
EAGAIN from protocols' read function. unix_read function returns 0 in
case of no data was read. It happens even if timeout it set for a valid
value and thus rw_timeout handling can not work and wait for ever. This
patch fixes the return value to AVERROR(EAGAIN) when recv()
reads/returns zero value/data and timeout is set.

please review this patch!

thank you in advance,

Bela Bodecs


-------------- next part --------------
>From f2fc0773500dd617a481ad67a195a811577f578a Mon Sep 17 00:00:00 2001
From: Bela Bodecs <bodecsb at vivanet.hu>
Date: Tue, 20 Mar 2018 20:38:22 +0100
Subject: [PATCH] avformat/unix: properly handling timeout at reading

avio rw_timeout handling in retry_transfer_wrapper is based on returning
EAGAIN from protocols' read function. unix_read function returns 0 in
case of no data was read. It happens even if timeout it set for a valid
value and thus rw_timeout handling can not work and wait for ever. This
patch fixes the return value to AVERROR(EAGAIN) when recv()
reads/returns zero value/data and timeout is set.

Signed-off-by: Bela Bodecs <bodecsb at vivanet.hu>
---
 libavformat/unix.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/unix.c b/libavformat/unix.c
index 4f01d14..1c1eec4 100644
--- a/libavformat/unix.c
+++ b/libavformat/unix.c
@@ -111,6 +111,8 @@ static int unix_read(URLContext *h, uint8_t *buf, int size)
             return ret;
     }
     ret = recv(s->fd, buf, size, 0);
+    if (!ret && s->timeout > -1)
+        return AVERROR(EAGAIN);
     return ret < 0 ? ff_neterrno() : ret;
 }
 
-- 
2.5.3.windows.1



More information about the ffmpeg-devel mailing list