mirror of https://github.com/aria2/aria2
				
				
				
			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.ccpull/1/head
							parent
							
								
									9be631e007
								
							
						
					
					
						commit
						22ada0cf32
					
				| 
						 | 
				
			
			@ -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>
 | 
			
		||||
 | 
			
		||||
	Added _logger->info() guard
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -697,6 +697,9 @@ std::string AbstractCommand::resolveHostname
 | 
			
		|||
  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)
 | 
			
		||||
{
 | 
			
		||||
  SharedHandle<CheckIntegrityEntry> entry
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -233,39 +233,35 @@ bool HttpResponseCommand::handleDefaultEncoding
 | 
			
		|||
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  _requestGroup->loadAndOpenFile(infoFile);
 | 
			
		||||
  File file(_requestGroup->getFirstFilePath());
 | 
			
		||||
  // We have to make sure that command that has Request object must
 | 
			
		||||
  // have segment after PieceStorage is initialized. See
 | 
			
		||||
  // AbstractCommand::execute()
 | 
			
		||||
  SharedHandle<Segment> segment =
 | 
			
		||||
    _requestGroup->getSegmentMan()->getSegment(cuid, 0);
 | 
			
		||||
  // pipelining requires implicit range specified. But the request for
 | 
			
		||||
  // this response most likely dones't contains range header. This means
 | 
			
		||||
  // we can't continue to use this socket because server sends all entity
 | 
			
		||||
  // body instead of a segment.
 | 
			
		||||
  // Therefore, we shutdown the socket here if pipelining is enabled.
 | 
			
		||||
  DownloadCommand* command = 0;
 | 
			
		||||
  try {
 | 
			
		||||
    _requestGroup->loadAndOpenFile(infoFile);
 | 
			
		||||
    File file(_requestGroup->getFirstFilePath());
 | 
			
		||||
 | 
			
		||||
    // We have to make sure that command that has Request object must
 | 
			
		||||
    // have segment after PieceStorage is initialized. See
 | 
			
		||||
    // AbstractCommand::execute()
 | 
			
		||||
    SharedHandle<Segment> segment =
 | 
			
		||||
      _requestGroup->getSegmentMan()->getSegment(cuid, 0);
 | 
			
		||||
    // pipelining requires implicit range specified. But the request for
 | 
			
		||||
    // this response most likely dones't contains range header. This means
 | 
			
		||||
    // we can't continue to use this socket because server sends all entity
 | 
			
		||||
    // body instead of a segment.
 | 
			
		||||
    // Therefore, we shutdown the socket here if pipelining is enabled.
 | 
			
		||||
    if(req->getMethod() == Request::METHOD_GET &&
 | 
			
		||||
       !segment.isNull() && segment->getPositionToWrite() == 0 &&
 | 
			
		||||
       !req->isPipeliningEnabled()) {
 | 
			
		||||
      command = createHttpDownloadCommand
 | 
			
		||||
        (httpResponse, getTransferEncodingDecoder(httpResponse));
 | 
			
		||||
    } else {
 | 
			
		||||
      _requestGroup->getSegmentMan()->cancelSegment(cuid);
 | 
			
		||||
      _fileEntry->poolRequest(req);
 | 
			
		||||
    }
 | 
			
		||||
    prepareForNextAction(command);
 | 
			
		||||
    if(req->getMethod() == Request::METHOD_HEAD) {
 | 
			
		||||
      poolConnection();
 | 
			
		||||
      req->setMethod(Request::METHOD_GET);
 | 
			
		||||
    }
 | 
			
		||||
  } catch(Exception& e) {
 | 
			
		||||
    delete command;
 | 
			
		||||
    throw;
 | 
			
		||||
  if(req->getMethod() == Request::METHOD_GET &&
 | 
			
		||||
     !segment.isNull() && segment->getPositionToWrite() == 0 &&
 | 
			
		||||
     !req->isPipeliningEnabled()) {
 | 
			
		||||
    command = createHttpDownloadCommand
 | 
			
		||||
      (httpResponse, getTransferEncodingDecoder(httpResponse));
 | 
			
		||||
  } else {
 | 
			
		||||
    _requestGroup->getSegmentMan()->cancelSegment(cuid);
 | 
			
		||||
    _fileEntry->poolRequest(req);
 | 
			
		||||
  }
 | 
			
		||||
  // After command is passed to prepareForNextAction(), it is managed
 | 
			
		||||
  // by CheckIntegrityEntry.
 | 
			
		||||
  prepareForNextAction(command);
 | 
			
		||||
  command = 0;
 | 
			
		||||
  if(req->getMethod() == Request::METHOD_HEAD) {
 | 
			
		||||
    poolConnection();
 | 
			
		||||
    req->setMethod(Request::METHOD_GET);
 | 
			
		||||
  }
 | 
			
		||||
  return true;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue