From bd78a36bd3300d6f93a4b94b7dd3f279914daeaa Mon Sep 17 00:00:00 2001 From: sukun Date: Fri, 9 Feb 2024 22:33:44 +0530 Subject: [PATCH] add rationale for maxTotalControlMessagesSize --- p2p/transport/webrtc/stream.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/p2p/transport/webrtc/stream.go b/p2p/transport/webrtc/stream.go index b7c91af079..42e90d5fad 100644 --- a/p2p/transport/webrtc/stream.go +++ b/p2p/transport/webrtc/stream.go @@ -22,8 +22,11 @@ const ( // https://github.com/pion/webrtc/blob/v3.1.49/sctptransport.go#L341 maxBufferedAmount = 2 * maxMessageSize // maxTotalControlMessagesSize is the maximum total size of all control messages we will - // write on this stream - maxTotalControlMessagesSize = 500 + // write on this stream. + // 4 control messages of size 10 bytes + 10 bytes buffer. This number doesn't need to be + // exact. In the worst case, we enqueue these many bytes more in the webrtc peer connection + // send queue. + maxTotalControlMessagesSize = 50 // bufferedAmountLowThreshold and maxBufferedAmount are bound // to a stream but congestion control is done on the whole // SCTP association. This means that a single stream can monopolize @@ -142,7 +145,6 @@ func (s *stream) Close() error { } s.mx.Unlock() - defer s.cleanup() closeWriteErr := s.CloseWrite() closeReadErr := s.CloseRead() if closeWriteErr != nil || closeReadErr != nil {