aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWofWca <wofwca@protonmail.com>2023-10-07 20:28:54 +0400
committerShelikhoo <xiaokangwang@outlook.com>2023-10-09 15:15:45 +0100
commita615e8b1ab88ac91a1a5588c1d6e41698e7af043 (patch)
tree5446f821a3e667de9e3a2647e9b3f2416a130df5
parentd434549df88292ff6e61830dc06a49b0ac1b21c6 (diff)
downloadsnowflake-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.go2
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
}
}