mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
fix(proxy): Correctly close connection pipe when dealing with error
This commit is contained in:
parent
6393af6bab
commit
7142fa3ddb
2 changed files with 11 additions and 5 deletions
|
@ -452,12 +452,17 @@ func (sf *SnowflakeProxy) makePeerConnectionFromOffer(sdp *webrtc.SessionDescrip
|
|||
var n int
|
||||
n, err = pw.Write(msg.Data)
|
||||
if err != nil {
|
||||
if inerr := pw.CloseWithError(err); inerr != nil {
|
||||
log.Printf("close with error generated an error: %v", inerr)
|
||||
if inErr := pw.CloseWithError(err); inErr != nil {
|
||||
log.Printf("close with error generated an error: %v", inErr)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
conn.bytesLogger.AddOutbound(int64(n))
|
||||
|
||||
if n != len(msg.Data) {
|
||||
// XXX: Maybe don't panic here and log an error instead?
|
||||
panic("short write")
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue