From 80035dd3b9ad74c32815b7f499f9b58998d311c9 Mon Sep 17 00:00:00 2001 From: wangguangsheng Date: Sun, 26 Jun 2022 01:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=20AcceptPipe=20=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E5=85=B6=E4=BB=96routine=E4=B8=AD=E8=B0=83=E7=94=A8Pi?= =?UTF-8?q?peListener=E7=9A=84Close=E6=96=B9=E6=B3=95=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=AD=BB=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- npipe_windows.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/npipe_windows.go b/npipe_windows.go index 5e7cf13..7a48cdd 100755 --- a/npipe_windows.go +++ b/npipe_windows.go @@ -305,7 +305,11 @@ func (l *PipeListener) AcceptPipe() (*PipeConn, error) { if err != nil { return nil, err } - defer syscall.CloseHandle(overlapped.HEvent) + defer func(){ + if overlapped.HEvent != 0 { + syscall.CloseHandle(overlapped.HEvent) + } + }() err = connectNamedPipe(handle, overlapped) if err == nil || err == error_pipe_connected { return &PipeConn{handle: handle, addr: l.addr}, nil