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>
|
||||
|
||||
Removed DiskAdaptor::onDownloadComplete()
|
||||
|
|
|
@ -70,7 +70,8 @@ DownloadCommand::DownloadCommand(int cuid,
|
|||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
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
|
||||
, _pieceHashValidationEnabled(false)
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
@ -110,8 +111,6 @@ bool DownloadCommand::executeInternal() {
|
|||
setReadCheckSocket(socket);
|
||||
SegmentHandle segment = _segments.front();
|
||||
|
||||
size_t BUFSIZE = 16*1024;
|
||||
unsigned char buf[BUFSIZE];
|
||||
size_t bufSize;
|
||||
if(segment->getLength() > 0) {
|
||||
if(segment->getPosition()+segment->getLength() <= static_cast<uint64_t>(_fileEntry->getLastOffset())) {
|
||||
|
@ -123,7 +122,7 @@ bool DownloadCommand::executeInternal() {
|
|||
} else {
|
||||
bufSize = BUFSIZE;
|
||||
}
|
||||
socket->readData(buf, bufSize);
|
||||
socket->readData(_buf, bufSize);
|
||||
|
||||
const SharedHandle<DiskAdaptor>& diskAdaptor =
|
||||
_requestGroup->getPieceStorage()->getDiskAdaptor();
|
||||
|
@ -133,10 +132,10 @@ bool DownloadCommand::executeInternal() {
|
|||
|
||||
std::string decoded;
|
||||
if(_transferEncodingDecoder.isNull()) {
|
||||
bufFinal = buf;
|
||||
bufFinal = _buf;
|
||||
bufSizeFinal = bufSize;
|
||||
} else {
|
||||
decoded = _transferEncodingDecoder->decode(buf, bufSize);
|
||||
decoded = _transferEncodingDecoder->decode(_buf, bufSize);
|
||||
|
||||
bufFinal = reinterpret_cast<const unsigned char*>(decoded.c_str());
|
||||
bufSizeFinal = decoded.size();
|
||||
|
|
|
@ -47,6 +47,10 @@ class MessageDigestContext;
|
|||
|
||||
class DownloadCommand : public AbstractCommand {
|
||||
private:
|
||||
static const size_t BUFSIZE = 16*1024;
|
||||
|
||||
unsigned char* _buf;
|
||||
|
||||
time_t startupIdleTime;
|
||||
unsigned int lowestDownloadSpeedLimit;
|
||||
SharedHandle<PeerStat> peerStat;
|
||||
|
|
Loading…
Reference in New Issue