summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-06-16 15:11:41 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-06-16 15:11:41 +0000
commit1c2dd30bf74200e1033fcb09ceec22a4e1f34e05 (patch)
treea21fa68650587760b4934ed7219bc7328fa464a6
parent953d1683a34541e6c58fa4b99ffdbe06376666fc (diff)
2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
When there is not enough space in disk when writing a chunk of data, aria2 now prints the message to the console to warn user and aborts its download. Not all downloads are canceled because some downloads may use another disk or partition. BUG#1640332 * src/AbstractDiskWriter.cc * src/PeerAbstractCommand.cc * src/PeerAbstractCommand.h: Added onFailure() function for override. * src/PeerInteractionCommand.cc: In onFailure(), call RequestGroup:: setHaltRequested(true) to cancel download. * src/PeerInteractionCommand.h
-rw-r--r--ChangeLog13
-rw-r--r--src/AbstractDiskWriter.cc7
-rw-r--r--src/PeerAbstractCommand.cc6
-rw-r--r--src/PeerAbstractCommand.h3
-rw-r--r--src/PeerInteractionCommand.cc6
-rw-r--r--src/PeerInteractionCommand.h1
6 files changed, 36 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 314a0a1e..1f16b249 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
+ When there is not enough space in disk when writing a chunk of data,
+ aria2 now prints the message to the console to warn user and aborts
+ its download. Not all downloads are canceled because some downloads
+ may use another disk or partition. BUG#1640332
+ * src/AbstractDiskWriter.cc
+ * src/PeerAbstractCommand.cc
+ * src/PeerAbstractCommand.h: Added onFailure() function for override.
+ * src/PeerInteractionCommand.cc: In onFailure(), call RequestGroup::
+ setHaltRequested(true) to cancel download.
+ * src/PeerInteractionCommand.h
+
+2008-06-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
+
Applied Ross's aria2-0.13.2+1-mingw-5.patch, which changes the type of
socket from int to sock_t as sockets are unsigned in Windows.
For AsyncNameResolver, DownloadEngine, I did additional modification
diff --git a/src/AbstractDiskWriter.cc b/src/AbstractDiskWriter.cc
index 1b86da28..afc3b7b7 100644
--- a/src/AbstractDiskWriter.cc
+++ b/src/AbstractDiskWriter.cc
@@ -41,6 +41,7 @@
#include "DlAbortEx.h"
#include "a2io.h"
#include "StringFormat.h"
+#include "DownloadFailureException.h"
#include <cerrno>
#include <cstring>
#include <cassert>
@@ -133,6 +134,12 @@ void AbstractDiskWriter::writeData(const unsigned char* data, size_t len, off_t
{
seek(offset);
if(writeDataInternal(data, len) < 0) {
+ // If errno is ENOSPC(not enough space in device), throw
+ // DownloadFailureException and abort download instantly.
+ if(errno == ENOSPC) {
+ throw DownloadFailureException
+ (StringFormat(EX_FILE_WRITE, filename.c_str(), strerror(errno)).str());
+ }
throw DlAbortEx(StringFormat(EX_FILE_WRITE, filename.c_str(), strerror(errno)).str());
}
}
diff --git a/src/PeerAbstractCommand.cc b/src/PeerAbstractCommand.cc
index 83118fa3..1cf11a03 100644
--- a/src/PeerAbstractCommand.cc
+++ b/src/PeerAbstractCommand.cc
@@ -41,6 +41,7 @@
#include "Logger.h"
#include "message.h"
#include "prefs.h"
+#include "DownloadFailureException.h"
namespace aria2 {
@@ -83,6 +84,11 @@ bool PeerAbstractCommand::execute() {
throw DlAbortEx(EX_TIME_OUT);
}
return executeInternal();
+ } catch(DownloadFailureException& err) {
+ logger->error(EX_DOWNLOAD_ABORTED, err);
+ onAbort();
+ onFailure();
+ return true;
} catch(RecoverableException& err) {
logger->debug(MSG_TORRENT_DOWNLOAD_ABORTED, err, cuid);
logger->debug(MSG_PEER_BANNED,
diff --git a/src/PeerAbstractCommand.h b/src/PeerAbstractCommand.h
index 95efdb99..76a0ce90 100644
--- a/src/PeerAbstractCommand.h
+++ b/src/PeerAbstractCommand.h
@@ -58,6 +58,9 @@ protected:
void setTimeout(time_t timeout) { this->timeout = timeout; }
virtual bool prepareForNextPeer(time_t wait);
virtual void onAbort() {};
+ // This function is called when DownloadFailureException is caught right after
+ // the invocation of onAbort().
+ virtual void onFailure() {};
virtual bool exitBeforeExecute() = 0;
virtual bool executeInternal() = 0;
void setReadCheckSocket(const SharedHandle<SocketCore>& socket);
diff --git a/src/PeerInteractionCommand.cc b/src/PeerInteractionCommand.cc
index d1e5fa5c..3ca8cc0c 100644
--- a/src/PeerInteractionCommand.cc
+++ b/src/PeerInteractionCommand.cc
@@ -63,6 +63,7 @@
#include "DHTSetup.h"
#include "DHTRegistry.h"
#include "PieceStorage.h"
+#include "RequestGroup.h"
#include <algorithm>
namespace aria2 {
@@ -276,6 +277,11 @@ void PeerInteractionCommand::onAbort() {
peerStorage->returnPeer(peer);
}
+void PeerInteractionCommand::onFailure()
+{
+ _requestGroup->setHaltRequested(true);
+}
+
bool PeerInteractionCommand::exitBeforeExecute()
{
return btRuntime->isHalt();
diff --git a/src/PeerInteractionCommand.h b/src/PeerInteractionCommand.h
index 525cac1d..b6533062 100644
--- a/src/PeerInteractionCommand.h
+++ b/src/PeerInteractionCommand.h
@@ -62,6 +62,7 @@ protected:
virtual bool executeInternal();
virtual bool prepareForNextPeer(time_t wait);
virtual void onAbort();
+ virtual void onFailure();
virtual bool exitBeforeExecute();
public:
PeerInteractionCommand(int32_t cuid,