path: root/lib/raidfile
diff options
authorChris Wilson <>2014-08-15 22:47:44 +0000
committerChris Wilson <>2014-08-15 22:47:44 +0000
commit4458bf17916973aeb9e99e9166070f645fb3295e (patch)
tree26dee42145e176b7ec3c3f233c79afc7b3270557 /lib/raidfile
parent06960c6241f6209b6dd19b4c204c27f1395cda7d (diff)
Fix deadlock waiting for read or write on closed connection.
If the system is suspended then it may not realise that a TCP connection has been closed, while waiting for data to arrive on it. We didn't used to apply a timeout to this read operation. Now we use the connection's default timeout on all read and write operations. Network operations that don't pass a timeout will be logged with a backtrace, so that they can be fixed.
Diffstat (limited to 'lib/raidfile')
4 files changed, 6 insertions, 4 deletions
diff --git a/lib/raidfile/RaidFileRead.cpp b/lib/raidfile/RaidFileRead.cpp
index 7591961f..a78ec4a2 100644
--- a/lib/raidfile/RaidFileRead.cpp
+++ b/lib/raidfile/RaidFileRead.cpp
@@ -1721,7 +1721,7 @@ bool RaidFileRead::ReadDirectoryContents(int SetNumber, const std::string &rDirN
// Created: 2003/08/21
// --------------------------------------------------------------------------
-void RaidFileRead::Write(const void *pBuffer, int NBytes)
+void RaidFileRead::Write(const void *pBuffer, int NBytes, int Timeout)
THROW_EXCEPTION(RaidFileException, UnsupportedReadWriteOrClose)
diff --git a/lib/raidfile/RaidFileRead.h b/lib/raidfile/RaidFileRead.h
index e746ed46..570443c8 100644
--- a/lib/raidfile/RaidFileRead.h
+++ b/lib/raidfile/RaidFileRead.h
@@ -56,7 +56,8 @@ public:
static bool ReadDirectoryContents(int SetNumber, const std::string &rDirName, int DirReadType, std::vector<std::string> &rOutput);
// Common IOStream interface implementation
- virtual void Write(const void *pBuffer, int NBytes);
+ virtual void Write(const void *pBuffer, int NBytes,
+ int Timeout = IOStream::TimeOutInfinite);
virtual bool StreamClosed();
virtual pos_type BytesLeftToRead();
diff --git a/lib/raidfile/RaidFileWrite.cpp b/lib/raidfile/RaidFileWrite.cpp
index 82aeef3d..ddc99fc7 100644
--- a/lib/raidfile/RaidFileWrite.cpp
+++ b/lib/raidfile/RaidFileWrite.cpp
@@ -243,7 +243,7 @@ void RaidFileWrite::Open(bool AllowOverwrite)
// Created: 2003/07/10
// --------------------------------------------------------------------------
-void RaidFileWrite::Write(const void *pBuffer, int Length)
+void RaidFileWrite::Write(const void *pBuffer, int Length, int Timeout)
// open?
if(mOSFileHandle == -1)
diff --git a/lib/raidfile/RaidFileWrite.h b/lib/raidfile/RaidFileWrite.h
index e2887167..4c5e8178 100644
--- a/lib/raidfile/RaidFileWrite.h
+++ b/lib/raidfile/RaidFileWrite.h
@@ -47,7 +47,8 @@ private:
// IOStream interface
virtual int Read(void *pBuffer, int NBytes, int Timeout = IOStream::TimeOutInfinite); // will exception
- virtual void Write(const void *pBuffer, int NBytes);
+ virtual void Write(const void *pBuffer, int NBytes,
+ int Timeout = IOStream::TimeOutInfinite);
virtual pos_type GetPosition() const;
virtual void Seek(pos_type Offset, int SeekType);
virtual void Close(); // will discard the file! Use commit instead.