void Connection::OnRead(ssize_t nread, const uv_buf_t* buf) {
    if (nread > 0) {
        OnReadData(nread);
    } else if (nread == 0) {
        OnReadEnd();
    } else {
        Close();
    }
}
int CIOCPFileAccessor::Update(int ProcessPacketLimit)
{
	int PacketCount1=0;
	int PacketCount2=0;
	
	COverLappedObject * pOverLappedObject;
	while(m_DataQueue.PopFront(pOverLappedObject))
	{			
		if(pOverLappedObject->GetType()==IO_FILE_READ)
		{
			ULONG64_CONVERTER ReadOffset;
			ReadOffset.HighPart=pOverLappedObject->GetOverlapped()->OffsetHigh;
			ReadOffset.LowPart=pOverLappedObject->GetOverlapped()->Offset;
			OnReadData(ReadOffset.QuadPart,*(pOverLappedObject->GetDataBuff()));
		}
		else
		{
			ULONG64_CONVERTER WriteOffset;
			WriteOffset.HighPart=pOverLappedObject->GetOverlapped()->OffsetHigh;
			WriteOffset.LowPart=pOverLappedObject->GetOverlapped()->Offset;
			OnWriteData(WriteOffset.QuadPart,*(pOverLappedObject->GetDataBuff()));
		}
		
			
		GetServer()->DeleteOverLappedObject(pOverLappedObject);
		PacketCount1++;
		if(PacketCount1>=ProcessPacketLimit)
			break;
	}

	FIOCP_ERROR_INFO ErrorInfo;
	while(m_ErrorQueue.PopFront(ErrorInfo))
	{			
		OnError(ErrorInfo.ErrorType,ErrorInfo.ErrorCode,ErrorInfo.QueryType,ErrorInfo.QueryPos,ErrorInfo.QuerySize);
		PacketCount2++;
		if(PacketCount2>=ProcessPacketLimit)
			break;
	}
	
	if(m_WantClose)
	{		
		Close();		
	}
	return PacketCount1+PacketCount2;
}