@@ -628,6 +628,13 @@ HRESULT DbgTransportSession::SendMessage(Message *pMessage, bool fWaitsForReply)
628
628
// queue).
629
629
pMessage->m_sHeader .m_dwLastSeenId = m_dwLastMessageIdSeen;
630
630
631
+ // Check the session state.
632
+ if (m_eState == SS_Closed)
633
+ {
634
+ // SS_Closed is bad news, we'll never recover from that so error the send immediately.
635
+ return E_ABORT;
636
+ }
637
+
631
638
// If the caller isn't waiting around for a reply we must make a copy of the message to place on the
632
639
// send queue.
633
640
pMessage->m_pOrigMessage = pMessage;
@@ -668,16 +675,14 @@ HRESULT DbgTransportSession::SendMessage(Message *pMessage, bool fWaitsForReply)
668
675
pMessage = pMessageCopy;
669
676
}
670
677
671
- // Check the session state.
672
- if (m_eState == SS_Closed )
678
+ // If the state is SS_Open we can send the message now .
679
+ if (m_eState == SS_Open )
673
680
{
674
- // SS_Closed is bad news, we'll never recover from that so error the send immediately.
675
- if (pMessageCopy)
676
- delete pMessageCopy;
677
- if (pDataBlockCopy)
678
- delete [] pDataBlockCopy;
679
-
680
- return E_ABORT;
681
+ // Send the message header block followed by the data block if it's provided. Any network error will
682
+ // be reported internally by SendBlock and result in a transition to the SS_Resync_NC state (and an
683
+ // eventual resend of the data).
684
+ if (SendBlock ((PBYTE)&pMessage->m_sHeader , sizeof (MessageHeader)) && pMessage->m_pbDataBlock )
685
+ SendBlock (pMessage->m_pbDataBlock , pMessage->m_cbDataBlock );
681
686
}
682
687
683
688
// Don't queue session management messages. We always recreate these if we need to re-send them.
@@ -700,15 +705,12 @@ HRESULT DbgTransportSession::SendMessage(Message *pMessage, bool fWaitsForReply)
700
705
pMessage->m_pNext = NULL ;
701
706
}
702
707
}
703
-
704
- // If the state is SS_Open we can send the message now.
705
- if (m_eState == SS_Open)
708
+ else
706
709
{
707
- // Send the message header block followed by the data block if it's provided. Any network error will
708
- // be reported internally by SendBlock and result in a transition to the SS_Resync_NC state (and an
709
- // eventual resend of the data).
710
- if (SendBlock ((PBYTE)&pMessage->m_sHeader , sizeof (MessageHeader)) && pMessage->m_pbDataBlock )
711
- SendBlock (pMessage->m_pbDataBlock , pMessage->m_cbDataBlock );
710
+ if (pMessageCopy)
711
+ delete pMessageCopy;
712
+ if (pDataBlockCopy)
713
+ delete [] pDataBlockCopy;
712
714
}
713
715
714
716
// If the state wasn't open there's nothing more to be done. The state will eventually transition to
0 commit comments