mirror of https://github.com/aria2/aria2
2009-07-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Allocate buffer in ctor of DownloadCommand. * src/DownloadCommand.cc * src/DownloadCommand.hpull/1/head
parent
6bd4447d23
commit
9263894689
|
@ -1,3 +1,9 @@
|
||||||
|
2009-07-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Allocate buffer in ctor of DownloadCommand.
|
||||||
|
* src/DownloadCommand.cc
|
||||||
|
* src/DownloadCommand.h
|
||||||
|
|
||||||
2009-07-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-07-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Removed DiskAdaptor::onDownloadComplete()
|
Removed DiskAdaptor::onDownloadComplete()
|
||||||
|
|
|
@ -70,7 +70,8 @@ DownloadCommand::DownloadCommand(int cuid,
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
const SocketHandle& s):
|
const SocketHandle& s):
|
||||||
AbstractCommand(cuid, req, fileEntry, requestGroup, e, s)
|
AbstractCommand(cuid, req, fileEntry, requestGroup, e, s),
|
||||||
|
_buf(new unsigned char[BUFSIZE])
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
, _pieceHashValidationEnabled(false)
|
, _pieceHashValidationEnabled(false)
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
@ -110,8 +111,6 @@ bool DownloadCommand::executeInternal() {
|
||||||
setReadCheckSocket(socket);
|
setReadCheckSocket(socket);
|
||||||
SegmentHandle segment = _segments.front();
|
SegmentHandle segment = _segments.front();
|
||||||
|
|
||||||
size_t BUFSIZE = 16*1024;
|
|
||||||
unsigned char buf[BUFSIZE];
|
|
||||||
size_t bufSize;
|
size_t bufSize;
|
||||||
if(segment->getLength() > 0) {
|
if(segment->getLength() > 0) {
|
||||||
if(segment->getPosition()+segment->getLength() <= static_cast<uint64_t>(_fileEntry->getLastOffset())) {
|
if(segment->getPosition()+segment->getLength() <= static_cast<uint64_t>(_fileEntry->getLastOffset())) {
|
||||||
|
@ -123,7 +122,7 @@ bool DownloadCommand::executeInternal() {
|
||||||
} else {
|
} else {
|
||||||
bufSize = BUFSIZE;
|
bufSize = BUFSIZE;
|
||||||
}
|
}
|
||||||
socket->readData(buf, bufSize);
|
socket->readData(_buf, bufSize);
|
||||||
|
|
||||||
const SharedHandle<DiskAdaptor>& diskAdaptor =
|
const SharedHandle<DiskAdaptor>& diskAdaptor =
|
||||||
_requestGroup->getPieceStorage()->getDiskAdaptor();
|
_requestGroup->getPieceStorage()->getDiskAdaptor();
|
||||||
|
@ -133,10 +132,10 @@ bool DownloadCommand::executeInternal() {
|
||||||
|
|
||||||
std::string decoded;
|
std::string decoded;
|
||||||
if(_transferEncodingDecoder.isNull()) {
|
if(_transferEncodingDecoder.isNull()) {
|
||||||
bufFinal = buf;
|
bufFinal = _buf;
|
||||||
bufSizeFinal = bufSize;
|
bufSizeFinal = bufSize;
|
||||||
} else {
|
} else {
|
||||||
decoded = _transferEncodingDecoder->decode(buf, bufSize);
|
decoded = _transferEncodingDecoder->decode(_buf, bufSize);
|
||||||
|
|
||||||
bufFinal = reinterpret_cast<const unsigned char*>(decoded.c_str());
|
bufFinal = reinterpret_cast<const unsigned char*>(decoded.c_str());
|
||||||
bufSizeFinal = decoded.size();
|
bufSizeFinal = decoded.size();
|
||||||
|
|
|
@ -47,6 +47,10 @@ class MessageDigestContext;
|
||||||
|
|
||||||
class DownloadCommand : public AbstractCommand {
|
class DownloadCommand : public AbstractCommand {
|
||||||
private:
|
private:
|
||||||
|
static const size_t BUFSIZE = 16*1024;
|
||||||
|
|
||||||
|
unsigned char* _buf;
|
||||||
|
|
||||||
time_t startupIdleTime;
|
time_t startupIdleTime;
|
||||||
unsigned int lowestDownloadSpeedLimit;
|
unsigned int lowestDownloadSpeedLimit;
|
||||||
SharedHandle<PeerStat> peerStat;
|
SharedHandle<PeerStat> peerStat;
|
||||||
|
|
Loading…
Reference in New Issue