diff options
author | WofWca <wofwca@protonmail.com> | 2023-10-07 20:28:54 +0400 |
---|---|---|
committer | Shelikhoo <xiaokangwang@outlook.com> | 2023-10-09 15:15:45 +0100 |
commit | a615e8b1ab88ac91a1a5588c1d6e41698e7af043 (patch) | |
tree | 5446f821a3e667de9e3a2647e9b3f2416a130df5 | |
parent | d434549df88292ff6e61830dc06a49b0ac1b21c6 (diff) | |
download | snowflake-a615e8b1ab88ac91a1a5588c1d6e41698e7af043.tar.gz snowflake-a615e8b1ab88ac91a1a5588c1d6e41698e7af043.zip |
fix(proxy): remove _potential_ deadlock
The `dc.Send()` should increase the `bufferedAmount` value,
so there is no need to add the message length a second time.
Also replace GT with GE, for the case where
`BufferedAmountLowThreshold === maxBufferedAmount`
Currently the deadlock cannot happen because `maxBufferedAmount`
and `BufferedAmountLowThreshold` are too far apart, in fact
the former is 2x the latter.
See
- https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/merge_requests/144#note_2902956
- https://github.com/pion/webrtc/pull/2473
- https://github.com/pion/webrtc/pull/2474
-rw-r--r-- | proxy/lib/webrtcconn.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/proxy/lib/webrtcconn.go b/proxy/lib/webrtcconn.go index ee656cb..f84734f 100644 --- a/proxy/lib/webrtcconn.go +++ b/proxy/lib/webrtcconn.go @@ -91,7 +91,7 @@ func (c *webRTCConn) Write(b []byte) (int, error) { defer c.lock.Unlock() if c.dc != nil { c.dc.Send(b) - if !c.isClosing && c.dc.BufferedAmount()+uint64(len(b)) > maxBufferedAmount { + if !c.isClosing && c.dc.BufferedAmount() >= maxBufferedAmount { <-c.sendMoreCh } } |