Mercurial > hg > svcore
diff data/fft/FFTFileCache.cpp @ 458:f60360209e5c
* Fix race condition in FFTFileCache when reading from the same FFT model
from multiple threads (e.g. when applying more than one plugin at once)
author | Chris Cannam |
---|---|
date | Wed, 15 Oct 2008 12:08:02 +0000 |
parents | 3e0f1f7bec85 |
children | 6066bde1c126 |
line wrap: on
line diff
--- a/data/fft/FFTFileCache.cpp Tue Oct 14 16:36:35 2008 +0000 +++ b/data/fft/FFTFileCache.cpp Wed Oct 15 12:08:02 2008 +0000 @@ -72,16 +72,21 @@ MutexLocker locker(&m_writeMutex, "FFTFileCache::resize::m_writeMutex"); m_mfc->resize(width, height * 2 + m_factorSize); - if (m_readbuf) { - delete[] m_readbuf; - m_readbuf = 0; + + { + MutexLocker locker(&m_readbufMutex, "FFTFileCache::resize::m_readMutex"); + if (m_readbuf) { + delete[] m_readbuf; + m_readbuf = 0; + } } + if (m_writebuf) { delete[] m_writebuf; } m_writebuf = new char[(height * 2 + m_factorSize) * m_mfc->getCellSize()]; } - + void FFTFileCache::reset() { @@ -302,7 +307,7 @@ } void -FFTFileCache::populateReadBuf(size_t x) const +FFTFileCache::populateReadBuf(size_t x) const // m_readbufMutex already held { Profiler profiler("FFTFileCache::populateReadBuf", false);