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/MultiDiskAdaptor.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/MultiDiskAdaptor.cc')
| -rw-r--r-- | src/MultiDiskAdaptor.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/MultiDiskAdaptor.cc b/src/MultiDiskAdaptor.cc index 17f3198d..3cb464ff 100644 --- a/src/MultiDiskAdaptor.cc +++ b/src/MultiDiskAdaptor.cc @@ -297,8 +297,20 @@ void MultiDiskAdaptor::openExistingFile() void MultiDiskAdaptor::closeFile() { - std::for_each(diskWriterEntries_.begin(), diskWriterEntries_.end(), - mem_fun_sh(&DiskWriterEntry::closeFile)); + bool ok = true; + for(std::vector<SharedHandle<DiskWriterEntry> >::const_iterator i = + diskWriterEntries_.begin(), eoi = diskWriterEntries_.end(); i != eoi; + ++i) { + try { + (*i)->closeFile(); + } catch(RecoverableException& e) { + A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e); + ok = false; + } + } + if(!ok) { + throw DL_ABORT_EX("Failed to close some files"); + } } namespace { |
