]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Limit the write buffer to work around a webrtc datachannel issue
authorMatt Joiner <anacrolix@gmail.com>
Sun, 3 May 2020 08:39:16 +0000 (18:39 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Sun, 3 May 2020 08:39:16 +0000 (18:39 +1000)
https://github.com/pion/datachannel/issues/59. Fixes https://github.com/anacrolix/torrent/issues/402.

peerconn.go

index 0e267a78a31bff77dbfeb25e42728cba831a406f..3e18544bf3645696027c409a43d3e6507e7fb9b7 100644 (file)
@@ -601,7 +601,9 @@ func (cn *PeerConn) writer(keepAliveTimeout time.Duration) {
                                cn.wroteMsg(&msg)
                                cn.writeBuffer.Write(msg.MustMarshalBinary())
                                torrent.Add(fmt.Sprintf("messages filled of type %s", msg.Type.String()), 1)
-                               return cn.writeBuffer.Len() < 1<<16 // 64KiB
+                               // 64KiB, but temporarily less to work around an issue with WebRTC. TODO: Update
+                               // when https://github.com/pion/datachannel/issues/59 is fixed.
+                               return cn.writeBuffer.Len() < 1<<15
                        })
                }
                if cn.writeBuffer.Len() == 0 && time.Since(lastWrite) >= keepAliveTimeout {