changeset 547:806e3c72b5df

* fix deadlock in fft memory cache usage
author Chris Cannam
date Wed, 04 Feb 2009 20:39:11 +0000
parents 95391b480e17
children 1469caaa8e67
files data/fft/FFTDataServer.h data/fileio/MatrixFile.cpp
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/data/fft/FFTDataServer.h	Wed Feb 04 15:03:42 2009 +0000
+++ b/data/fft/FFTDataServer.h	Wed Feb 04 20:39:11 2009 +0000
@@ -171,7 +171,10 @@
         m_cacheVectorLock.lockForRead();
         CacheBlock *cb(m_caches.at(c));
         if (cb) {
-            if (cb->memoryCache) return cb->memoryCache;
+            if (cb->memoryCache) {
+                m_cacheVectorLock.unlock();
+                return cb->memoryCache;
+            }
             if (cb->fileCacheWriter) {
                 QThread *me = QThread::currentThread();
                 CacheBlock::ThreadReaderMap &map = cb->fileCacheReader;
--- a/data/fileio/MatrixFile.cpp	Wed Feb 04 15:03:42 2009 +0000
+++ b/data/fileio/MatrixFile.cpp	Wed Feb 04 20:39:11 2009 +0000
@@ -209,7 +209,7 @@
     }
 
     if (::lseek(m_fd, 0, SEEK_SET) < 0) {
-        ::perror("ERROR: MatrixFile::resize: Seek to write header failed");
+        ::perror("ERROR: MatrixFile::initialise: Seek to write header failed");
         throw FileOperationFailed(m_fileName, "lseek");
     }
 
@@ -217,7 +217,7 @@
     header[0] = m_width;
     header[1] = m_height;
     if (::write(m_fd, header, 2 * sizeof(size_t)) != 2 * sizeof(size_t)) {
-        ::perror("ERROR: MatrixFile::resize: Failed to write header");
+        ::perror("ERROR: MatrixFile::initialise: Failed to write header");
         throw FileOperationFailed(m_fileName, "write");
     }
 
@@ -226,7 +226,7 @@
     }
 
 #ifdef DEBUG_MATRIX_FILE
-    std::cerr << "MatrixFile[" << m_fd << "]::resize(" << m_width << ", " << m_height << "): storage "
+    std::cerr << "MatrixFile[" << m_fd << "]::initialise(" << m_width << ", " << m_height << "): storage "
               << (m_headerSize + m_width * m_height * m_cellSize + m_width) << std::endl;
 
     std::cerr << "MatrixFile: Total storage " << totalStorage/1024 << "K" << std::endl;