This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit a22037858ee2c6105a108f3a7964bff73609ba02 Author: Niklas Haas <[email protected]> AuthorDate: Wed Jun 10 14:20:51 2026 +0200 Commit: Niklas Haas <[email protected]> CommitDate: Sun Jun 14 11:10:12 2026 +0200 avformat/shared: use flock() instead of fcntl() flock() also locks against accesses by other threads of the same process, unlike fcntl(). Sponsored-by: nxtedition AB Signed-off-by: Niklas Haas <[email protected]> --- libavformat/shared.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavformat/shared.c b/libavformat/shared.c index 136bd7af27..e5f495aa99 100644 --- a/libavformat/shared.c +++ b/libavformat/shared.c @@ -371,8 +371,7 @@ static int cache_map(URLContext *h, int64_t filesize) static int spacemap_remap(URLContext *h, size_t map_size) { SharedContext *s = h->priv_data; - struct flock fl = { .l_type = F_WRLCK }; - int ret, did_grow = 0; + int ret, did_grow = 0, locked = 0; if (map_size <= s->map_size) return 0; @@ -388,12 +387,12 @@ static int spacemap_remap(URLContext *h, size_t map_size) goto skip_resize; /* Lock the spacemap to ensure nobody else is currently resizing it */ - ret = fcntl(s->mapfd, F_SETLKW, &fl); + ret = flock(s->mapfd, LOCK_EX); if (ret < 0) { ret = AVERROR(errno); goto fail; } - fl.l_type = F_UNLCK; + locked = 1; /* Refresh filesize after acquiring the lock */ ret = fstat(s->mapfd, &st); @@ -425,15 +424,16 @@ skip_resize: goto fail; } - /* fl.l_type is set to F_UNLCK only after successful lock */ - if (fl.l_type == F_UNLCK) - fcntl(s->mapfd, F_SETLK, &fl); + if (locked) { + flock(s->mapfd, LOCK_UN); + locked = 0; + } return did_grow; fail: - if (fl.l_type == F_UNLCK) - fcntl(s->mapfd, F_SETLK, &fl); + if (locked) + flock(s->mapfd, LOCK_UN); av_log(h, AV_LOG_ERROR, "Failed to resize space map: %s\n", av_err2str(ret)); return ret; } _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
