mirror of https://github.com/aria2/aria2
2010-11-10 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Retry open(2) and fallocate(2) when they are interrupted by signal. * src/AbstractDiskWriter.ccpull/1/head
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>
|
2010-11-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Capture errno right after system/library call to avoid it to get
|
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;
|
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;
|
int errNum = errno;
|
||||||
throw DL_ABORT_EX2
|
throw DL_ABORT_EX2
|
||||||
(errNum,
|
(errNum,
|
||||||
|
@ -112,8 +114,10 @@ void AbstractDiskWriter::createFile(int addFlags)
|
||||||
{
|
{
|
||||||
assert(!filename_.empty());
|
assert(!filename_.empty());
|
||||||
util::mkdirs(File(filename_).getDirname());
|
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;
|
int errNum = errno;
|
||||||
throw DL_ABORT_EX2
|
throw DL_ABORT_EX2
|
||||||
(errNum,
|
(errNum,
|
||||||
|
@ -222,7 +226,8 @@ void AbstractDiskWriter::allocate(off_t offset, uint64_t length)
|
||||||
# ifdef HAVE_FALLOCATE
|
# ifdef HAVE_FALLOCATE
|
||||||
// For linux, we use fallocate to detect file system supports
|
// For linux, we use fallocate to detect file system supports
|
||||||
// fallocate or not.
|
// 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;
|
int errNum = errno;
|
||||||
if(r == -1) {
|
if(r == -1) {
|
||||||
throw DL_ABORT_EX(StringFormat("fallocate failed. cause: %s",
|
throw DL_ABORT_EX(StringFormat("fallocate failed. cause: %s",
|
||||||
|
|
Loading…
Reference in New Issue