Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_sched: fix race on SchFilter.send_finished (PR #21249)
Date: Sat, 20 Dec 2025 15:46:44 -0000
Message-ID: <176624560543.60.10050840498309401912@2cb04c0e5124> (raw)

PR #21249 opened by Niklas Haas (haasn)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21249
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21249.patch

This logic was previously added to the scheduler. That commit added locking
(and rescheduling) when updating the corresponding `receive_finished` flag,
but missed doing the same for `send_finished`.

Fixes: fd1fd5850de4f3beb240422b67889bb776b26c77


>From d23908d12611b4873dbd1548de61e4a5ac45f277 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Sat, 20 Dec 2025 16:43:40 +0100
Subject: [PATCH] fftools/ffmpeg_sched: fix race on SchFilter.send_finished

This logic was previously added to the scheduler. That commit added locking
(and rescheduling) when updating the corresponding `receive_finished` flag,
but missed doing the same for `send_finished`.

Fixes: fd1fd5850de4f3beb240422b67889bb776b26c77
---
 fftools/ffmpeg_sched.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index c5ee6971f1..862c002b85 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -2297,6 +2297,8 @@ static int send_to_filter(Scheduler *sch, SchFilterGraph *fg,
     if (frame)
         return tq_send(fg->queue, in_idx, frame);
 
+    pthread_mutex_lock(&sch->schedule_lock);
+
     if (!fg->inputs[in_idx].send_finished) {
         fg->inputs[in_idx].send_finished = 1;
         tq_send_finish(fg->queue, in_idx);
@@ -2304,7 +2306,11 @@ static int send_to_filter(Scheduler *sch, SchFilterGraph *fg,
         // close the control stream when all actual inputs are done
         if (atomic_fetch_add(&fg->nb_inputs_finished_send, 1) == fg->nb_inputs - 1)
             tq_send_finish(fg->queue, fg->nb_inputs);
+
+        schedule_update_locked(sch);
     }
+
+    pthread_mutex_unlock(&sch->schedule_lock);
     return 0;
 }
 
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2025-12-20 15:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=176624560543.60.10050840498309401912@2cb04c0e5124 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git