mirror of
https://github.com/aria2/aria2.git
synced 2025-01-04 09:03:46 +00:00
2010-11-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Retry open(2) and fallocate(2) when they are interrupted by signal. * src/AbstractDiskWriter.cc
This commit is contained in:
parent
228b4c50d7
commit
f1af13567f
@ -1,3 +1,9 @@
|
||||
2010-11-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Retry open(2) and fallocate(2) when they are interrupted by
|
||||
signal.
|
||||
* src/AbstractDiskWriter.cc
|
||||
|
||||
2010-11-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||
|
||||
Capture errno right after system/library call to avoid it to get
|
||||
|
@ -98,7 +98,9 @@ void AbstractDiskWriter::openExistingFile(uint64_t totalLength)
|
||||
flags |= O_RDWR;
|
||||
}
|
||||
|
||||
if((fd_ = open(filename_.c_str(), flags, OPEN_MODE)) < 0) {
|
||||
while((fd_ = open(filename_.c_str(), flags, OPEN_MODE)) == -1 &&
|
||||
errno == EINTR);
|
||||
if(fd_ < 0) {
|
||||
int errNum = errno;
|
||||
throw DL_ABORT_EX2
|
||||
(errNum,
|
||||
@ -112,8 +114,10 @@ void AbstractDiskWriter::createFile(int addFlags)
|
||||
{
|
||||
assert(!filename_.empty());
|
||||
util::mkdirs(File(filename_).getDirname());
|
||||
if((fd_ = open(filename_.c_str(), O_CREAT|O_RDWR|O_TRUNC|O_BINARY|addFlags,
|
||||
OPEN_MODE)) < 0) {
|
||||
|
||||
while((fd_ = open(filename_.c_str(), O_CREAT|O_RDWR|O_TRUNC|O_BINARY|addFlags,
|
||||
OPEN_MODE)) == -1 && errno == EINTR);
|
||||
if(fd_ < 0) {
|
||||
int errNum = errno;
|
||||
throw DL_ABORT_EX2
|
||||
(errNum,
|
||||
@ -222,7 +226,8 @@ void AbstractDiskWriter::allocate(off_t offset, uint64_t length)
|
||||
# ifdef HAVE_FALLOCATE
|
||||
// For linux, we use fallocate to detect file system supports
|
||||
// fallocate or not.
|
||||
int r = fallocate(fd_, 0, offset, length);
|
||||
int r;
|
||||
while((r = fallocate(fd_, 0, offset, length)) == -1 && errno == EINTR);
|
||||
int errNum = errno;
|
||||
if(r == -1) {
|
||||
throw DL_ABORT_EX(StringFormat("fallocate failed. cause: %s",
|
||||
|
Loading…
Reference in New Issue
Block a user