mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Call explicit frees in client
This commit is contained in:
parent
ee4e0aa160
commit
f6301197cc
1 changed files with 7 additions and 3 deletions
|
@ -147,7 +147,7 @@ func (c *WebRTCPeer) Connect() error {
|
||||||
// Create and prepare callbacks on a new WebRTC PeerConnection.
|
// Create and prepare callbacks on a new WebRTC PeerConnection.
|
||||||
func (c *WebRTCPeer) preparePeerConnection() error {
|
func (c *WebRTCPeer) preparePeerConnection() error {
|
||||||
if nil != c.pc {
|
if nil != c.pc {
|
||||||
c.pc.Close()
|
c.pc.Destroy()
|
||||||
c.pc = nil
|
c.pc = nil
|
||||||
}
|
}
|
||||||
pc, err := webrtc.NewPeerConnection(c.config)
|
pc, err := webrtc.NewPeerConnection(c.config)
|
||||||
|
@ -230,6 +230,7 @@ func (c *WebRTCPeer) establishDataChannel() error {
|
||||||
// Disable the DataChannel as a write destination.
|
// Disable the DataChannel as a write destination.
|
||||||
log.Println("WebRTC: DataChannel.OnClose [remotely]")
|
log.Println("WebRTC: DataChannel.OnClose [remotely]")
|
||||||
c.transport = nil
|
c.transport = nil
|
||||||
|
c.pc.DeleteDataChannel(dc)
|
||||||
c.Close()
|
c.Close()
|
||||||
}
|
}
|
||||||
dc.OnMessage = func(msg []byte) {
|
dc.OnMessage = func(msg []byte) {
|
||||||
|
@ -326,11 +327,14 @@ func (c *WebRTCPeer) cleanup() {
|
||||||
// Setting transport to nil *before* dc Close indicates to OnClose that
|
// Setting transport to nil *before* dc Close indicates to OnClose that
|
||||||
// this was locally triggered.
|
// this was locally triggered.
|
||||||
c.transport = nil
|
c.transport = nil
|
||||||
dataChannel.Close()
|
if c.pc == nil {
|
||||||
|
panic("DataChannel w/o PeerConnection, not good.")
|
||||||
|
}
|
||||||
|
c.pc.DeleteDataChannel(dataChannel.(*webrtc.DataChannel))
|
||||||
}
|
}
|
||||||
if nil != c.pc {
|
if nil != c.pc {
|
||||||
log.Printf("WebRTC: closing PeerConnection")
|
log.Printf("WebRTC: closing PeerConnection")
|
||||||
err := c.pc.Close()
|
err := c.pc.Destroy()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
log.Printf("Error closing peerconnection...")
|
log.Printf("Error closing peerconnection...")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue