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 <anton@khirnov.net>
This commit is contained in:
parent
59d96941f0
commit
55815edca0
2
ffmpeg.c
2
ffmpeg.c
@ -3733,7 +3733,7 @@ static void opt_output_file(const char *filename)
|
|||||||
(strchr(filename, ':') == NULL ||
|
(strchr(filename, ':') == NULL ||
|
||||||
filename[1] == ':' ||
|
filename[1] == ':' ||
|
||||||
av_strstart(filename, "file:", NULL))) {
|
av_strstart(filename, "file:", NULL))) {
|
||||||
if (url_exist(filename)) {
|
if (avio_check(filename, 0) == 0) {
|
||||||
if (!using_stdin) {
|
if (!using_stdin) {
|
||||||
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
|
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
@ -3679,7 +3679,7 @@ static void build_feed_streams(void)
|
|||||||
for(feed = first_feed; feed != NULL; feed = feed->next_feed) {
|
for(feed = first_feed; feed != NULL; feed = feed->next_feed) {
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
if (url_exist(feed->feed_filename)) {
|
if (avio_check(feed->feed_filename, AVIO_FLAG_READ) > 0) {
|
||||||
/* See if it matches */
|
/* See if it matches */
|
||||||
AVFormatContext *s;
|
AVFormatContext *s;
|
||||||
int matches = 0;
|
int matches = 0;
|
||||||
@ -3752,7 +3752,7 @@ static void build_feed_streams(void)
|
|||||||
unlink(feed->feed_filename);
|
unlink(feed->feed_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!url_exist(feed->feed_filename)) {
|
if (avio_check(feed->feed_filename, AVIO_FLAG_WRITE) <= 0) {
|
||||||
AVFormatContext s1 = {0}, *s = &s1;
|
AVFormatContext s1 = {0}, *s = &s1;
|
||||||
|
|
||||||
if (feed->readonly) {
|
if (feed->readonly) {
|
||||||
|
@ -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){
|
if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){
|
||||||
*pfirst_index =
|
*pfirst_index =
|
||||||
*plast_index = 1;
|
*plast_index = 1;
|
||||||
if(url_exist(buf))
|
if (avio_check(buf, AVIO_FLAG_READ) > 0)
|
||||||
return 0;
|
return 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (url_exist(buf))
|
if (avio_check(buf, AVIO_FLAG_READ) > 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (first_index == 5)
|
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,
|
if (av_get_frame_filename(buf, sizeof(buf), path,
|
||||||
last_index + range1) < 0)
|
last_index + range1) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (!url_exist(buf))
|
if (avio_check(buf, AVIO_FLAG_READ) <= 0)
|
||||||
break;
|
break;
|
||||||
range = range1;
|
range = range1;
|
||||||
/* just in case... */
|
/* just in case... */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user