Commit 132d6fae authored by Łukasz Magiera's avatar Łukasz Magiera

p2p: Only use reset on streams

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent 8b7bf266
......@@ -386,7 +386,7 @@ var p2pStreamCloseCmd = &cmds.Command{
if !closeAll && handlerID != stream.Id {
continue
}
stream.Close()
stream.Reset()
if !closeAll {
break
}
......
......@@ -27,14 +27,6 @@ type Stream struct {
Registry *StreamRegistry
}
// 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
}
// Reset closes stream endpoints and deregisters it
func (s *Stream) Reset() error {
s.Local.Close()
......@@ -45,21 +37,13 @@ func (s *Stream) Reset() error {
func (s *Stream) startStreaming() {
go func() {
_, err := io.Copy(s.Local, s.Remote)
if err != nil {
s.Reset()
} else {
s.Close()
}
io.Copy(s.Local, s.Remote)
s.Reset()
}()
go func() {
_, err := io.Copy(s.Remote, s.Local)
if err != nil {
s.Reset()
} else {
s.Close()
}
io.Copy(s.Remote, s.Local)
s.Reset()
}()
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment