diff --git a/app/proxyman/mux/mux.go b/app/proxyman/mux/mux.go index d6925c2c..17943df2 100644 --- a/app/proxyman/mux/mux.go +++ b/app/proxyman/mux/mux.go @@ -133,8 +133,8 @@ func (m *Client) monitor() { select { case <-m.done.Wait(): m.sessionManager.Close() - common.Close(m.link.Writer) - pipe.CloseError(m.link.Reader) + common.Close(m.link.Writer) // nolint: errcheck + pipe.CloseError(m.link.Reader) // nolint: errcheck return case <-timer.C: size := m.sessionManager.Size() @@ -167,14 +167,15 @@ func fetchInput(ctx context.Context, s *Session, output buf.Writer) { } s.transferType = transferType writer := NewWriter(s.ID, dest, output, transferType) - defer s.Close() - defer writer.Close() + defer s.Close() // nolint: errcheck + defer writer.Close() // nolint: errcheck newError("dispatching request to ", dest).WithContext(ctx).WriteToLog() if pReader, ok := s.input.(*pipe.Reader); ok { if err := copyFirstPayload(pReader, writer); err != nil { newError("failed to fetch first payload").Base(err).WithContext(ctx).WriteToLog() writer.hasError = true + pipe.CloseError(s.input) return } } @@ -182,6 +183,7 @@ func fetchInput(ctx context.Context, s *Session, output buf.Writer) { if err := buf.Copy(s.input, writer); err != nil { newError("failed to fetch all input").Base(err).WithContext(ctx).WriteToLog() writer.hasError = true + pipe.CloseError(s.input) return } } diff --git a/app/proxyman/mux/session.go b/app/proxyman/mux/session.go index 6dcccc1b..c1ff4032 100644 --- a/app/proxyman/mux/session.go +++ b/app/proxyman/mux/session.go @@ -118,8 +118,8 @@ func (m *SessionManager) Close() error { m.closed = true for _, s := range m.sessions { - common.Close(s.input) - common.Close(s.output) + common.Close(s.input) // nolint: errcheck + common.Close(s.output) // nolint: errcheck } m.sessions = nil @@ -137,8 +137,8 @@ type Session struct { // Close closes all resources associated with this session. func (s *Session) Close() error { - common.Close(s.output) - common.Close(s.input) + common.Close(s.output) // nolint: errcheck + common.Close(s.input) // nolint: errcheck s.parent.Remove(s.ID) return nil } diff --git a/app/proxyman/mux/writer.go b/app/proxyman/mux/writer.go index ed0f938f..d7fb839d 100644 --- a/app/proxyman/mux/writer.go +++ b/app/proxyman/mux/writer.go @@ -102,6 +102,7 @@ func (w *Writer) WriteMultiBuffer(mb buf.MultiBuffer) error { return nil } +// Close implements common.Closable. func (w *Writer) Close() error { meta := FrameMetadata{ SessionID: w.id, @@ -114,6 +115,6 @@ func (w *Writer) Close() error { frame := buf.New() common.Must(meta.WriteTo(frame)) - w.writer.WriteMultiBuffer(buf.NewMultiBufferValue(frame)) + w.writer.WriteMultiBuffer(buf.NewMultiBufferValue(frame)) // nolint: errcheck return nil }