From be7f386c99bcd8767dd40e275eedbe5599bcfeda Mon Sep 17 00:00:00 2001 From: Yoshida Hiroshi Date: Thu, 7 Nov 2024 15:37:47 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E6=99=82=E3=81=AE?= =?UTF-8?q?=20close=20=E5=87=A6=E7=90=86=E3=82=92=E5=85=A5=E3=82=8C?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/handler.go b/handler.go index f9675b1..209d825 100644 --- a/handler.go +++ b/handler.go @@ -235,8 +235,6 @@ func readPacketWithHeader(reader io.Reader) (io.Reader, error) { r, w := io.Pipe() go func() { - defer w.Close() - length := 0 payloadLength := 0 var payload []byte @@ -245,7 +243,7 @@ func readPacketWithHeader(reader io.Reader) (io.Reader, error) { buf := make([]byte, 20+0xffff) n, err := reader.Read(buf) if err != nil { - // TODO: ログ出力 + w.CloseWithError(err) return } @@ -261,7 +259,7 @@ func readPacketWithHeader(reader io.Reader) (io.Reader, error) { if length == (20 + payloadLength) { if _, err := w.Write(p); err != nil { - // TODO: ログ出力 + w.CloseWithError(err) return } payload = []byte{} @@ -279,7 +277,7 @@ func readPacketWithHeader(reader io.Reader) (io.Reader, error) { // 次の frame が含まれている場合 if length > (20 + payloadLength) { if _, err := w.Write(p[:payloadLength]); err != nil { - // TODO: ログ出力 + w.CloseWithError(err) return } // 次の payload 処理へ @@ -297,7 +295,7 @@ func readPacketWithHeader(reader io.Reader) (io.Reader, error) { // すでに次の payload が全てある場合 if length == (20 + payloadLength) { if _, err := w.Write(p); err != nil { - // TODO: ログ出力 + w.CloseWithError(err) return } payload = []byte{} @@ -307,7 +305,7 @@ func readPacketWithHeader(reader io.Reader) (io.Reader, error) { if length > (20 + payloadLength) { if _, err := w.Write(p[:payloadLength]); err != nil { - // TODO: ログ出力 + w.CloseWithError(err) return }