[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit f6301197cc154781cfa96a5255c47c9977887f02
Author: Arlo Breault <arlolra@xxxxxxxxx>
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...")
 		}

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits