mirror of https://github.com/aria2/aria2
No retry for close() with EINTR. Also reverted changes in d5ffa253
.
parent
8865001f01
commit
52155b1860
|
@ -59,10 +59,7 @@ AbstractDiskWriter::AbstractDiskWriter(const std::string& filename)
|
||||||
|
|
||||||
AbstractDiskWriter::~AbstractDiskWriter()
|
AbstractDiskWriter::~AbstractDiskWriter()
|
||||||
{
|
{
|
||||||
try {
|
closeFile();
|
||||||
closeFile();
|
|
||||||
} catch(...) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractDiskWriter::openFile(off_t totalLength)
|
void AbstractDiskWriter::openFile(off_t totalLength)
|
||||||
|
@ -80,18 +77,9 @@ void AbstractDiskWriter::openFile(off_t totalLength)
|
||||||
|
|
||||||
void AbstractDiskWriter::closeFile()
|
void AbstractDiskWriter::closeFile()
|
||||||
{
|
{
|
||||||
if(fd_ >= 0) {
|
if(fd_ != -1) {
|
||||||
int r;
|
close(fd_);
|
||||||
while((r = close(fd_)) == -1 && errno == EINTR);
|
|
||||||
fd_ = -1;
|
fd_ = -1;
|
||||||
if(r == -1) {
|
|
||||||
int errNum = errno;
|
|
||||||
throw DL_ABORT_EX3(errNum,
|
|
||||||
fmt("Failed to close file %s, cause: %s",
|
|
||||||
filename_.c_str(),
|
|
||||||
util::safeStrerror(errNum).c_str()),
|
|
||||||
error_code::FILE_IO_ERROR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,7 @@ EpollEventPoll::EpollEventPoll()
|
||||||
EpollEventPoll::~EpollEventPoll()
|
EpollEventPoll::~EpollEventPoll()
|
||||||
{
|
{
|
||||||
if(epfd_ != -1) {
|
if(epfd_ != -1) {
|
||||||
int r;
|
int r = close(epfd_);
|
||||||
while((r = close(epfd_)) == -1 && errno == EINTR);
|
|
||||||
int errNum = errno;
|
int errNum = errno;
|
||||||
if(r == -1) {
|
if(r == -1) {
|
||||||
A2_LOG_ERROR(fmt("Error occurred while closing epoll file descriptor"
|
A2_LOG_ERROR(fmt("Error occurred while closing epoll file descriptor"
|
||||||
|
|
|
@ -97,8 +97,7 @@ KqueueEventPoll::KqueueEventPoll()
|
||||||
KqueueEventPoll::~KqueueEventPoll()
|
KqueueEventPoll::~KqueueEventPoll()
|
||||||
{
|
{
|
||||||
if(kqfd_ != -1) {
|
if(kqfd_ != -1) {
|
||||||
int r;
|
int r = close(kqfd_);
|
||||||
while((r = close(kqfd_)) == -1 && errno == EINTR);
|
|
||||||
int errNum = errno;
|
int errNum = errno;
|
||||||
if(r == -1) {
|
if(r == -1) {
|
||||||
A2_LOG_ERROR(fmt("Error occurred while closing kqueue file descriptor"
|
A2_LOG_ERROR(fmt("Error occurred while closing kqueue file descriptor"
|
||||||
|
|
|
@ -297,20 +297,8 @@ void MultiDiskAdaptor::openExistingFile()
|
||||||
|
|
||||||
void MultiDiskAdaptor::closeFile()
|
void MultiDiskAdaptor::closeFile()
|
||||||
{
|
{
|
||||||
bool ok = true;
|
std::for_each(diskWriterEntries_.begin(), diskWriterEntries_.end(),
|
||||||
for(std::vector<SharedHandle<DiskWriterEntry> >::const_iterator i =
|
mem_fun_sh(&DiskWriterEntry::closeFile));
|
||||||
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 {
|
namespace {
|
||||||
|
|
|
@ -86,8 +86,7 @@ PortEventPoll::PortEventPoll()
|
||||||
PortEventPoll::~PortEventPoll()
|
PortEventPoll::~PortEventPoll()
|
||||||
{
|
{
|
||||||
if(port_ != -1) {
|
if(port_ != -1) {
|
||||||
int r;
|
int r = close(port_);
|
||||||
while((r = close(port_)) == -1 && errno == EINTR);
|
|
||||||
int errNum = errno;
|
int errNum = errno;
|
||||||
if(r == -1) {
|
if(r == -1) {
|
||||||
A2_LOG_ERROR(fmt("Error occurred while closing port %d: %s",
|
A2_LOG_ERROR(fmt("Error occurred while closing port %d: %s",
|
||||||
|
|
|
@ -554,11 +554,7 @@ void RequestGroupMan::closeFile()
|
||||||
{
|
{
|
||||||
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
for(std::deque<SharedHandle<RequestGroup> >::const_iterator itr =
|
||||||
requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
|
requestGroups_.begin(), eoi = requestGroups_.end(); itr != eoi; ++itr) {
|
||||||
try {
|
(*itr)->closeFile();
|
||||||
(*itr)->closeFile();
|
|
||||||
} catch(RecoverableException& e) {
|
|
||||||
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace aria2 {
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
# define CLOSE(X) ::closesocket(X)
|
# define CLOSE(X) ::closesocket(X)
|
||||||
#else
|
#else
|
||||||
# define CLOSE(X) while(close(X) == -1 && errno == EINTR)
|
# define CLOSE(X) close(X)
|
||||||
#endif // __MINGW32__
|
#endif // __MINGW32__
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
Loading…
Reference in New Issue