Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
p2p
go-p2p-secio
Commits
76fa877f
Commit
76fa877f
authored
Nov 28, 2016
by
Jeromy Johnson
Committed by
GitHub
Nov 28, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10 from libp2p/fix/mem-leak
be more careful about holding onto things forever
parents
d26dd414
995821d3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
4 deletions
+4
-4
interface.go
interface.go
+0
-1
protocol.go
protocol.go
+2
-3
rw_test.go
rw_test.go
+2
-0
No files found.
interface.go
View file @
76fa877f
...
...
@@ -82,7 +82,6 @@ func (s *secureSession) RemotePublicKey() ci.PubKey {
// Close closes the secure session
func
(
s
*
secureSession
)
Close
()
error
{
s
.
cancel
()
s
.
handshakeMu
.
Lock
()
defer
s
.
handshakeMu
.
Unlock
()
if
s
.
secure
==
nil
{
...
...
protocol.go
View file @
76fa877f
...
...
@@ -41,8 +41,7 @@ const nonceSize = 16
// secureSession encapsulates all the parameters needed for encrypting
// and decrypting traffic from an insecure channel.
type
secureSession
struct
{
ctx
context
.
Context
cancel
context
.
CancelFunc
ctx
context
.
Context
secure
msgio
.
ReadWriteCloser
insecure
io
.
ReadWriteCloser
...
...
@@ -72,7 +71,6 @@ func (s *secureSession) Loggable() map[string]interface{} {
func
newSecureSession
(
ctx
context
.
Context
,
local
peer
.
ID
,
key
ci
.
PrivKey
,
insecure
io
.
ReadWriteCloser
)
(
*
secureSession
,
error
)
{
s
:=
&
secureSession
{
localPeer
:
local
,
localKey
:
key
}
s
.
ctx
,
s
.
cancel
=
context
.
WithCancel
(
ctx
)
switch
{
case
s
.
localPeer
==
""
:
...
...
@@ -110,6 +108,7 @@ func (s *secureSession) Handshake() error {
// keys, IDs, and initiate communication, assigning all necessary params.
// requires the duplex channel to be a msgio.ReadWriter (for framed messaging)
func
(
s
*
secureSession
)
runHandshake
()
error
{
defer
func
()
{
s
.
ctx
=
nil
}()
// clear to save memory
ctx
,
cancel
:=
context
.
WithTimeout
(
s
.
ctx
,
HandshakeTimeout
)
// remove
defer
cancel
()
...
...
rw_test.go
View file @
76fa877f
...
...
@@ -82,4 +82,6 @@ func TestBasicETMStream(t *testing.T) {
if
string
(
before
)
!=
string
(
msg
)
{
t
.
Fatal
(
"got wrong message"
)
}
r
.
Close
()
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment