Skip to content

Commit 3668ad5

Browse files
author
anytls
committed
fix(session): call hook in closeLocally
1 parent d7adb5c commit 3668ad5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

proxy/session/stream.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,20 @@ func (s *Stream) Close() error {
6464
return s.closeWithError(io.ErrClosedPipe)
6565
}
6666

67-
// closeLocally only closes Stream and don't call Session or dieHook
67+
// closeLocally only closes Stream and don't notify remote peer
6868
func (s *Stream) closeLocally() {
69+
var once bool
6970
s.dieOnce.Do(func() {
7071
s.dieErr = net.ErrClosed
7172
s.pipeR.Close()
73+
once = true
7274
})
75+
if once {
76+
if s.dieHook != nil {
77+
s.dieHook()
78+
s.dieHook = nil
79+
}
80+
}
7381
}
7482

7583
func (s *Stream) closeWithError(err error) error {

0 commit comments

Comments
 (0)