[tor-commits] [snowflake/master] Call explicit frees in client

arlo at torproject.org arlo at torproject.org
Tue Mar 6 00:00:07 UTC 2018


commit f6301197cc154781cfa96a5255c47c9977887f02
Author: Arlo Breault <arlolra at gmail.com>
Date:   Thu Mar 1 00:14:59 2018 -0500

    Call explicit frees in client
---
 client/webrtc.go | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/client/webrtc.go b/client/webrtc.go
index 0f80678..e35c47d 100644
--- a/client/webrtc.go
+++ b/client/webrtc.go
@@ -147,7 +147,7 @@ func (c *WebRTCPeer) Connect() error {
 // Create and prepare callbacks on a new WebRTC PeerConnection.
 func (c *WebRTCPeer) preparePeerConnection() error {
 	if nil != c.pc {
-		c.pc.Close()
+		c.pc.Destroy()
 		c.pc = nil
 	}
 	pc, err := webrtc.NewPeerConnection(c.config)
@@ -230,6 +230,7 @@ func (c *WebRTCPeer) establishDataChannel() error {
 		// Disable the DataChannel as a write destination.
 		log.Println("WebRTC: DataChannel.OnClose [remotely]")
 		c.transport = nil
+		c.pc.DeleteDataChannel(dc)
 		c.Close()
 	}
 	dc.OnMessage = func(msg []byte) {
@@ -326,11 +327,14 @@ func (c *WebRTCPeer) cleanup() {
 		// Setting transport to nil *before* dc Close indicates to OnClose that
 		// this was locally triggered.
 		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 {
 		log.Printf("WebRTC: closing PeerConnection")
-		err := c.pc.Close()
+		err := c.pc.Destroy()
 		if nil != err {
 			log.Printf("Error closing peerconnection...")
 		}



More information about the tor-commits mailing list