mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 09:50:06 +00:00 
			
		
		
		
	Ignore message segments when first segment doesn't start at 1
This commit is contained in:
		
							parent
							
								
									dbda117284
								
							
						
					
					
						commit
						53717434a6
					
				
					 1 changed files with 43 additions and 28 deletions
				
			
		|  | @ -53,6 +53,7 @@ struct Level2MessageFactory::Context | |||
|    size_t            bufferedSize_; | ||||
|    util::vectorbuf   messageBuffer_; | ||||
|    std::istream      messageBufferStream_; | ||||
|    bool              bufferingData_ {false}; | ||||
| }; | ||||
| 
 | ||||
| std::shared_ptr<Level2MessageFactory::Context> | ||||
|  | @ -103,8 +104,19 @@ Level2MessageInfo Level2MessageFactory::Create(std::istream&            is, | |||
|             ctx->messageData_.resize(dataSize * totalSegments); | ||||
|             ctx->messageBufferStream_.clear(); | ||||
|             ctx->bufferedSize_  = 0; | ||||
|             ctx->bufferingData_ = true; | ||||
|          } | ||||
|          else if (!ctx->bufferingData_) | ||||
|          { | ||||
|             // Segment number did not start at 1
 | ||||
|             logger_->trace("Ignoring Segment {}/{}, did not start at 1", | ||||
|                            segment, | ||||
|                            totalSegments); | ||||
|             info.messageValid = false; | ||||
|          } | ||||
| 
 | ||||
|          if (ctx->bufferingData_) | ||||
|          { | ||||
|             if (ctx->messageData_.capacity() < ctx->bufferedSize_ + dataSize) | ||||
|             { | ||||
|                logger_->debug("Bad size estimate, increasing size"); | ||||
|  | @ -126,6 +138,7 @@ Level2MessageInfo Level2MessageFactory::Create(std::istream&            is, | |||
|                info.messageValid = false; | ||||
|                ctx->messageData_.shrink_to_fit(); | ||||
|                ctx->bufferedSize_  = 0; | ||||
|                ctx->bufferingData_ = false; | ||||
|             } | ||||
|             else if (segment == totalSegments) | ||||
|             { | ||||
|  | @ -136,6 +149,7 @@ Level2MessageInfo Level2MessageFactory::Create(std::istream&            is, | |||
|                messageStream = &ctx->messageBufferStream_; | ||||
|             } | ||||
|          } | ||||
|       } | ||||
| 
 | ||||
|       if (messageStream != nullptr) | ||||
|       { | ||||
|  | @ -145,6 +159,7 @@ Level2MessageInfo Level2MessageFactory::Create(std::istream&            is, | |||
|          ctx->messageData_.shrink_to_fit(); | ||||
|          ctx->messageBufferStream_.clear(); | ||||
|          ctx->bufferedSize_  = 0; | ||||
|          ctx->bufferingData_ = false; | ||||
|       } | ||||
|    } | ||||
|    else if (info.headerValid) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat