comparison data/fileio/MatrixFile.cpp @ 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
comparison
equal deleted inserted replaced
546:95391b480e17 547:806e3c72b5df
207 ::perror("ERROR: MatrixFile::initialise: write at end failed"); 207 ::perror("ERROR: MatrixFile::initialise: write at end failed");
208 throw FileOperationFailed(m_fileName, "write"); 208 throw FileOperationFailed(m_fileName, "write");
209 } 209 }
210 210
211 if (::lseek(m_fd, 0, SEEK_SET) < 0) { 211 if (::lseek(m_fd, 0, SEEK_SET) < 0) {
212 ::perror("ERROR: MatrixFile::resize: Seek to write header failed"); 212 ::perror("ERROR: MatrixFile::initialise: Seek to write header failed");
213 throw FileOperationFailed(m_fileName, "lseek"); 213 throw FileOperationFailed(m_fileName, "lseek");
214 } 214 }
215 215
216 size_t header[2]; 216 size_t header[2];
217 header[0] = m_width; 217 header[0] = m_width;
218 header[1] = m_height; 218 header[1] = m_height;
219 if (::write(m_fd, header, 2 * sizeof(size_t)) != 2 * sizeof(size_t)) { 219 if (::write(m_fd, header, 2 * sizeof(size_t)) != 2 * sizeof(size_t)) {
220 ::perror("ERROR: MatrixFile::resize: Failed to write header"); 220 ::perror("ERROR: MatrixFile::initialise: Failed to write header");
221 throw FileOperationFailed(m_fileName, "write"); 221 throw FileOperationFailed(m_fileName, "write");
222 } 222 }
223 223
224 if (m_mode == WriteOnly) { 224 if (m_mode == WriteOnly) {
225 totalStorage += (m_headerSize + (m_width * m_height * m_cellSize) + m_width); 225 totalStorage += (m_headerSize + (m_width * m_height * m_cellSize) + m_width);
226 } 226 }
227 227
228 #ifdef DEBUG_MATRIX_FILE 228 #ifdef DEBUG_MATRIX_FILE
229 std::cerr << "MatrixFile[" << m_fd << "]::resize(" << m_width << ", " << m_height << "): storage " 229 std::cerr << "MatrixFile[" << m_fd << "]::initialise(" << m_width << ", " << m_height << "): storage "
230 << (m_headerSize + m_width * m_height * m_cellSize + m_width) << std::endl; 230 << (m_headerSize + m_width * m_height * m_cellSize + m_width) << std::endl;
231 231
232 std::cerr << "MatrixFile: Total storage " << totalStorage/1024 << "K" << std::endl; 232 std::cerr << "MatrixFile: Total storage " << totalStorage/1024 << "K" << std::endl;
233 #endif 233 #endif
234 234