2010-06-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Fixed double memory free when Exception raised from
	AbstractCommand::prepareForNextAction() called by
	HttpResponseCommand::handleDefaultEncoding().
	* src/AbstractCommand.cc
	* src/HttpResponseCommand.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-06-01 12:40:57 +00:00
parent 9be631e007
commit 22ada0cf32
3 changed files with 39 additions and 32 deletions

View File

@ -1,3 +1,11 @@
2010-06-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed double memory free when Exception raised from
AbstractCommand::prepareForNextAction() called by
HttpResponseCommand::handleDefaultEncoding().
* src/AbstractCommand.cc
* src/HttpResponseCommand.cc
2010-06-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net> 2010-06-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added _logger->info() guard Added _logger->info() guard

View File

@ -697,6 +697,9 @@ std::string AbstractCommand::resolveHostname
return ipaddr; return ipaddr;
} }
// nextCommand is going to be managed by CheckIntegrityEntry which is
// created in side this function. Don't release nextCommand after this
// function call.
void AbstractCommand::prepareForNextAction(Command* nextCommand) void AbstractCommand::prepareForNextAction(Command* nextCommand)
{ {
SharedHandle<CheckIntegrityEntry> entry SharedHandle<CheckIntegrityEntry> entry

View File

@ -233,12 +233,8 @@ bool HttpResponseCommand::handleDefaultEncoding
return true; return true;
} }
DownloadCommand* command = 0;
try {
_requestGroup->loadAndOpenFile(infoFile); _requestGroup->loadAndOpenFile(infoFile);
File file(_requestGroup->getFirstFilePath()); File file(_requestGroup->getFirstFilePath());
// We have to make sure that command that has Request object must // We have to make sure that command that has Request object must
// have segment after PieceStorage is initialized. See // have segment after PieceStorage is initialized. See
// AbstractCommand::execute() // AbstractCommand::execute()
@ -249,6 +245,7 @@ bool HttpResponseCommand::handleDefaultEncoding
// we can't continue to use this socket because server sends all entity // we can't continue to use this socket because server sends all entity
// body instead of a segment. // body instead of a segment.
// Therefore, we shutdown the socket here if pipelining is enabled. // Therefore, we shutdown the socket here if pipelining is enabled.
DownloadCommand* command = 0;
if(req->getMethod() == Request::METHOD_GET && if(req->getMethod() == Request::METHOD_GET &&
!segment.isNull() && segment->getPositionToWrite() == 0 && !segment.isNull() && segment->getPositionToWrite() == 0 &&
!req->isPipeliningEnabled()) { !req->isPipeliningEnabled()) {
@ -258,15 +255,14 @@ bool HttpResponseCommand::handleDefaultEncoding
_requestGroup->getSegmentMan()->cancelSegment(cuid); _requestGroup->getSegmentMan()->cancelSegment(cuid);
_fileEntry->poolRequest(req); _fileEntry->poolRequest(req);
} }
// After command is passed to prepareForNextAction(), it is managed
// by CheckIntegrityEntry.
prepareForNextAction(command); prepareForNextAction(command);
command = 0;
if(req->getMethod() == Request::METHOD_HEAD) { if(req->getMethod() == Request::METHOD_HEAD) {
poolConnection(); poolConnection();
req->setMethod(Request::METHOD_GET); req->setMethod(Request::METHOD_GET);
} }
} catch(Exception& e) {
delete command;
throw;
}
return true; return true;
} }