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
dms3
go-dms3
Commits
6a1d7097
Commit
6a1d7097
authored
May 22, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: turns out we need half-open streams
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
cf6ddcbf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
p2p/outbound.go
p2p/outbound.go
+1
-0
p2p/stream.go
p2p/stream.go
+15
-3
No files found.
p2p/outbound.go
View file @
6a1d7097
...
...
@@ -44,6 +44,7 @@ func (p2p *P2P) Dial(ctx context.Context, peer peer.ID, proto string, bindAddr m
listener
:
maListener
,
}
p2p
.
Listeners
.
Register
(
listener
)
go
listener
.
acceptConns
()
return
listener
,
nil
...
...
p2p/stream.go
View file @
6a1d7097
...
...
@@ -27,7 +27,15 @@ type Stream struct {
Registry
*
StreamRegistry
}
// Reset closes stream endpoints and deregisters it
// Close closes stream endpoints and deregisters it
func
(
s
*
Stream
)
Close
()
error
{
s
.
Local
.
Close
()
s
.
Remote
.
Close
()
s
.
Registry
.
Deregister
(
s
.
Id
)
return
nil
}
// Rest closes stream endpoints and deregisters it
func
(
s
*
Stream
)
Reset
()
error
{
s
.
Local
.
Close
()
s
.
Remote
.
Reset
()
...
...
@@ -42,8 +50,12 @@ func (s *Stream) startStreaming() {
}()
go
func
()
{
io
.
Copy
(
s
.
Remote
,
s
.
Local
)
s
.
Reset
()
_
,
err
:=
io
.
Copy
(
s
.
Remote
,
s
.
Local
)
if
err
!=
nil
{
s
.
Reset
()
}
else
{
s
.
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