[FFmpeg-devel] [PATCH 1/2] avutil/buffer: always fetch the pool atomically.

Clément Bœsch u at pkh.me
Mon May 26 21:18:58 CEST 2014


---
So, after the recent threads patches, valgrind DRD (helgrind and tsan didn't
went through yet) went from 1199 to 1215 passing tests (on a total of 1937)
after the thread changes. It's better but it's far from being perfect. I had a
quick look to some random entries, and it was complaining in that place.

I'm not convince this is an appropriate change since I'm not familiar with that
stuff, but it might help. Please comment.
---
 libavutil/buffer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavutil/buffer.c b/libavutil/buffer.c
index e9bf54b..de97b1c 100644
--- a/libavutil/buffer.c
+++ b/libavutil/buffer.c
@@ -249,14 +249,14 @@ void av_buffer_pool_uninit(AVBufferPool **ppool)
 /* remove the whole buffer list from the pool and return it */
 static BufferPoolEntry *get_pool(AVBufferPool *pool)
 {
-    BufferPoolEntry *cur = *(void * volatile *)&pool->pool, *last = NULL;
+    BufferPoolEntry *cur = NULL, *last;
 
-    while (cur != last) {
+    do {
         last = cur;
         cur = avpriv_atomic_ptr_cas((void * volatile *)&pool->pool, last, NULL);
         if (!cur)
             return NULL;
-    }
+    } while (cur != last);
 
     return cur;
 }
-- 
1.9.3



More information about the ffmpeg-devel mailing list