mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 06:03:02 +01:00
Fixed potentially lost original error code when IO error happens.
This commit is contained in:
parent
081dcb572a
commit
0b0891c89a
@ -97,12 +97,12 @@ namespace
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void raiseIOError(const char* syscall, const char* filename)
|
void raiseIOError(const char* syscall, const char* filename, ISC_STATUS errcode)
|
||||||
{
|
{
|
||||||
Arg::Gds temp(isc_io_error);
|
Arg::Gds temp(isc_io_error);
|
||||||
temp << Arg::Str(syscall);
|
temp << Arg::Str(syscall);
|
||||||
temp << Arg::Str(filename);
|
temp << Arg::Str(filename);
|
||||||
temp << SYS_ERR(ERRNO);
|
temp << SYS_ERR(errcode);
|
||||||
temp.raise();
|
temp.raise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ void ChangeLog::Segment::copyTo(const PathName& filename) const
|
|||||||
fb_assert(m_header != &m_builtinHeader);
|
fb_assert(m_header != &m_builtinHeader);
|
||||||
|
|
||||||
if (os_utils::lseek(m_handle, 0, SEEK_SET) != 0)
|
if (os_utils::lseek(m_handle, 0, SEEK_SET) != 0)
|
||||||
raiseIOError("seek", m_filename.c_str());
|
raiseIOError("seek", m_filename.c_str(), ERRNO);
|
||||||
|
|
||||||
const auto totalLength = m_header->hdr_length;
|
const auto totalLength = m_header->hdr_length;
|
||||||
fb_assert(totalLength > sizeof(SegmentHeader));
|
fb_assert(totalLength > sizeof(SegmentHeader));
|
||||||
@ -193,16 +193,20 @@ void ChangeLog::Segment::copyTo(const PathName& filename) const
|
|||||||
|
|
||||||
if (::read(m_handle, data, length) != length)
|
if (::read(m_handle, data, length) != length)
|
||||||
{
|
{
|
||||||
|
const ISC_STATUS errcode = ERRNO;
|
||||||
|
|
||||||
dstFile.release();
|
dstFile.release();
|
||||||
unlink(filename.c_str());
|
unlink(filename.c_str());
|
||||||
raiseIOError("read", m_filename.c_str());
|
raiseIOError("read", m_filename.c_str(), errcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::write(dstFile, data, length) != length)
|
if (::write(dstFile, data, length) != length)
|
||||||
{
|
{
|
||||||
|
const ISC_STATUS errcode = ERRNO;
|
||||||
|
|
||||||
dstFile.release();
|
dstFile.release();
|
||||||
unlink(filename.c_str());
|
unlink(filename.c_str());
|
||||||
raiseIOError("write", filename.c_str());
|
raiseIOError("write", filename.c_str(), errcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user