diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-12-09 23:32:38 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-12-09 23:32:38 +0900 |
| commit | d5ffa2532da9283abaf18d5ca4e58d07a8b2f405 (patch) | |
| tree | 25ce2972b76194c42f1b283f814f837d53b10c25 /src/AbstractDiskWriter.cc | |
| parent | 9a6f88c162bc49d8e5bbefdcd2cf239706c3d0d9 (diff) | |
AbstractDiskWriter::closeFile(): Throw exception if close() failed.
~AbstractDiskWriter calles closeFile(), but suppresses exception.
MultiDiskAdaptor::closeFile() logs error if child
DiskWriter::closeFile() throws exception. This exception is not
rethrown. If at least one exception is caught,
MultiDiskAdaptor::closeFile() throws new DlAbortEx.
RequestGroupMan::closeFile() just logs exception and suppress each
exception. Generally, don't call closeFile() in destructor. If you
need to call it, it must suppress the exception.
Diffstat (limited to 'src/AbstractDiskWriter.cc')
| -rw-r--r-- | src/AbstractDiskWriter.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc index e209018a..fb6a0174 100644 --- a/src/AbstractDiskWriter.cc +++ b/src/AbstractDiskWriter.cc @@ -59,7 +59,10 @@ AbstractDiskWriter::AbstractDiskWriter(const std::string& filename) AbstractDiskWriter::~AbstractDiskWriter() { - closeFile(); + try { + closeFile(); + } catch(...) { + } } void AbstractDiskWriter::openFile(off_t totalLength) @@ -78,8 +81,15 @@ void AbstractDiskWriter::openFile(off_t totalLength) void AbstractDiskWriter::closeFile() { if(fd_ >= 0) { - close(fd_); + int r; + while((r = close(fd_)) == -1 && errno == EINTR); fd_ = -1; + if(r == -1) { + int errNum = errno; + throw DL_ABORT_EX3(errNum, fmt("Failed to close file: %s", + util::safeStrerror(errNum).c_str()), + error_code::FILE_IO_ERROR); + } } } |
