From 9a04f8df1a7b5c8f32b4a7540d31113f629e2165 Mon Sep 17 00:00:00 2001 From: phintuka Date: Tue, 21 Jul 2009 09:48:35 +0000 Subject: Fixed possible race condition in Flush() --- tools/backgroundwriter.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/backgroundwriter.c b/tools/backgroundwriter.c index a4296d91..aa321dd7 100644 --- a/tools/backgroundwriter.c +++ b/tools/backgroundwriter.c @@ -4,7 +4,7 @@ * See the main source file 'xineliboutput.c' for copyright information and * how to reach the author. * - * $Id: backgroundwriter.c,v 1.8 2009-03-18 21:05:26 phintuka Exp $ + * $Id: backgroundwriter.c,v 1.9 2009-07-21 09:48:35 phintuka Exp $ * */ @@ -105,7 +105,8 @@ bool cBackgroundWriterI::Flush(int TimeoutMs) cCondWait::SleepMs(3); } - if(m_IsSocket && m_RingBuffer.Available() <= 0) { + int Available = m_RingBuffer.Available(); + if(m_IsSocket && Available <= 0) { // flush corked data too #if defined(TCP_CORK) int i = 1; @@ -122,8 +123,8 @@ bool cBackgroundWriterI::Flush(int TimeoutMs) } #endif } - - return m_RingBuffer.Available() <= 0; + + return Available <= 0; } -- cgit v1.2.3