diff mbox

[FFmpeg-devel] pthread_frame: revert 2e664b9c1e73c80aab91070c1eb7676f04bdd12d.

Message ID 20170718161109.19163-1-wtc@google.com
State Accepted
Commit 58fbcf885d97d9b83c54cc57e3631c76caa208cf
Headers show

Commit Message

Wan-Teh Chang July 18, 2017, 4:11 p.m. UTC
The patch does not fix the tsan warning it was intended to fix.
Reverting the patch moves the av_log() back to the outside of the lock.

Signed-off-by: Wan-Teh Chang <wtc@google.com>
---
 libavcodec/pthread_frame.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Ronald S. Bultje July 27, 2017, 9:22 p.m. UTC | #1
Hi,

On Tue, Jul 18, 2017 at 12:11 PM, Wan-Teh Chang <
wtc-at-google.com@ffmpeg.org> wrote:

> The patch does not fix the tsan warning it was intended to fix.
> Reverting the patch moves the av_log() back to the outside of the lock.
>
> Signed-off-by: Wan-Teh Chang <wtc@google.com>
> ---
>  libavcodec/pthread_frame.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)


Pushed.

Ronald
diff mbox

Patch

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 2cea232a36..08e182c3d1 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -570,11 +570,12 @@  void ff_thread_report_progress(ThreadFrame *f, int n, int field)
 
     p = f->owner[field]->internal->thread_ctx;
 
-    pthread_mutex_lock(&p->progress_mutex);
     if (atomic_load_explicit(&p->debug_threads, memory_order_relaxed))
         av_log(f->owner[field], AV_LOG_DEBUG,
                "%p finished %d field %d\n", progress, n, field);
 
+    pthread_mutex_lock(&p->progress_mutex);
+
     atomic_store_explicit(&progress[field], n, memory_order_release);
 
     pthread_cond_broadcast(&p->progress_cond);
@@ -592,10 +593,11 @@  void ff_thread_await_progress(ThreadFrame *f, int n, int field)
 
     p = f->owner[field]->internal->thread_ctx;
 
-    pthread_mutex_lock(&p->progress_mutex);
     if (atomic_load_explicit(&p->debug_threads, memory_order_relaxed))
         av_log(f->owner[field], AV_LOG_DEBUG,
                "thread awaiting %d field %d from %p\n", n, field, progress);
+
+    pthread_mutex_lock(&p->progress_mutex);
     while (atomic_load_explicit(&progress[field], memory_order_relaxed) < n)
         pthread_cond_wait(&p->progress_cond, &p->progress_mutex);
     pthread_mutex_unlock(&p->progress_mutex);