History

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.

Stefano Sabatini committed 15 years ago

Commit 55815ed1 parent 59d96943 files · +6 −6Browse files

Unified · Split

3 files
  1. ffmpeg.c +1 −1
  2. ffserver.c +2 −2
  3. libavformat/img2.c +3 −3
ffmpeg.c+1−1
@@ -3733,7 +3733,7 @@ static void opt_output_file(const char *filename) · 3732 unmodified lines
37333733 (strchr(filename, ':') == NULL ||
37343734 filename[1] == ':' ||
37353735 av_strstart(filename, "file:", NULL))) {
3736− if (url_exist(filename)) {
3736+ if (avio_check(filename, 0) == 0) {
37373737 if (!using_stdin) {
37383738 fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
37393739 fflush(stderr);
ffserver.c+2−2
@@ -3679,7 +3679,7 @@ static void build_feed_streams(void) · 3678 unmodified lines
36793679 for(feed = first_feed; feed != NULL; feed = feed->next_feed) {
36803680 int fd;
36813681
3682− if (url_exist(feed->feed_filename)) {
3682+ if (avio_check(feed->feed_filename, AVIO_FLAG_READ) > 0) {
36833683 /* See if it matches */
36843684 AVFormatContext *s;
36853685 int matches = 0;
@@ -3752,7 +3752,7 @@ static void build_feed_streams(void) · 66 unmodified lines
37523752 unlink(feed->feed_filename);
37533753 }
37543754 }
3755− if (!url_exist(feed->feed_filename)) {
3755+ if (avio_check(feed->feed_filename, AVIO_FLAG_WRITE) <= 0) {
37563756 AVFormatContext s1 = {0}, *s = &s1;
37573757
37583758 if (feed->readonly) {
libavformat/img2.c+3−3
@@ -131,11 +131,11 @@ static int find_image_range(int *pfirst_index, int *plast_index, · 130 unmodified lines
131131 if (av_get_frame_filename(buf, sizeof(buf), path, first_index) < 0){
132132 *pfirst_index =
133133 *plast_index = 1;
134− if(url_exist(buf))
134+ if (avio_check(buf, AVIO_FLAG_READ) > 0)
135135 return 0;
136136 return -1;
137137 }
138− if (url_exist(buf))
138+ if (avio_check(buf, AVIO_FLAG_READ) > 0)
139139 break;
140140 }
141141 if (first_index == 5)
@@ -153,7 +153,7 @@ static int find_image_range(int *pfirst_index, int *plast_index, · 11 unmodified lines
153153 if (av_get_frame_filename(buf, sizeof(buf), path,
154154 last_index + range1) < 0)
155155 goto fail;
156− if (!url_exist(buf))
156+ if (avio_check(buf, AVIO_FLAG_READ) <= 0)
157157 break;
158158 range = range1;
159159 /* just in case... */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t