dcsctp: Add consistency check for assembled msgs

The buffer of reassembled messages in ReassemblyQueue is only to be
used while processing a DATA/I-DATA or FORWARD-TSN as processing these
chunks may result in assembling messages.

When the socket is idle - between API calls - it's supposed to be empty.

Instead of having it as a member in ReassemblyQueue, it could be
provided as an argument to ReassemblyQueue::Add and
ReassemblyQueue::Handle(ForwardTSN), but that would be a quite big
refactoring. That will be investigated separately.

Bug: None
Change-Id: I41238de28f32f2a622c1d045debe3ea11e7c23f6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232000
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35014}
diff --git a/net/dcsctp/socket/dcsctp_socket.cc b/net/dcsctp/socket/dcsctp_socket.cc
index 2983b0f..5211cca 100644
--- a/net/dcsctp/socket/dcsctp_socket.cc
+++ b/net/dcsctp/socket/dcsctp_socket.cc
@@ -184,6 +184,9 @@
 }
 
 bool DcSctpSocket::IsConsistent() const {
+  if (tcb_ != nullptr && tcb_->reassembly_queue().HasMessages()) {
+    return false;
+  }
   switch (state_) {
     case State::kClosed:
       return (tcb_ == nullptr && !t1_init_->is_running() &&