From 55815edca038997ec283569a192a3eca7f2143bc Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sat, 9 Apr 2011 01:32:37 +0200 Subject: prefer avio_check() over url_exist() The problem with url_exist() is that it tries to open a resource in RDONLY mode. If the file is a FIFO and there is already a reading client, the open() call will hang. By using avio_check() with access mode of 0, the second reading process will check if the file exists without attempting to open it, thus avoiding the lock. Fix issue #1663. Signed-off-by: Anton Khirnov --- libavformat/img2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libavformat/img2.c') diff --git a/libavformat/img2.c b/libavformat/img2.c index 84d841f0ed..1d50fbf567 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -131,11 +131,11 @@ static int find_image_range(int *pfirst_index, int *plast_index, if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){ *pfirst_index = *plast_index = 1; - if(url_exist(buf)) + if (avio_check(buf, AVIO_FLAG_READ) > 0) return 0; return -1; } - if (url_exist(buf)) + if (avio_check(buf, AVIO_FLAG_READ) > 0) break; } if (first_index == 5) @@ -153,7 +153,7 @@ static int find_image_range(int *pfirst_index, int *plast_index, if (av_get_frame_filename(buf, sizeof(buf), path, last_index + range1) < 0) goto fail; - if (!url_exist(buf)) + if (avio_check(buf, AVIO_FLAG_READ) <= 0) break; range = range1; /* just in case... */ -- cgit v1.2.3