From d6382072c9769ce7d824321baf0f67e9f8ab1528 Mon Sep 17 00:00:00 2001 From: Tetsuya Morimoto Date: Mon, 1 Apr 2024 14:52:42 +0900 Subject: [PATCH 1/2] Refactor the context handling with receiving an ldap response in searchAsync() #495 --- response.go | 4 +--- v3/response.go | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/response.go b/response.go index 1abe02a3..dbb36c2b 100644 --- a/response.go +++ b/response.go @@ -102,9 +102,7 @@ func (r *searchResponse) start(ctx context.Context, searchRequest *SearchRequest case <-ctx.Done(): r.conn.Debug.Printf("%d: %s", msgCtx.id, ctx.Err().Error()) return - default: - r.conn.Debug.Printf("%d: waiting for response", msgCtx.id) - packetResponse, ok := <-msgCtx.responses + case packetResponse, ok := <-msgCtx.responses: if !ok { err := NewError(ErrorNetwork, errors.New("ldap: response channel closed")) r.ch <- &SearchSingleResult{Error: err} diff --git a/v3/response.go b/v3/response.go index 1abe02a3..dbb36c2b 100644 --- a/v3/response.go +++ b/v3/response.go @@ -102,9 +102,7 @@ func (r *searchResponse) start(ctx context.Context, searchRequest *SearchRequest case <-ctx.Done(): r.conn.Debug.Printf("%d: %s", msgCtx.id, ctx.Err().Error()) return - default: - r.conn.Debug.Printf("%d: waiting for response", msgCtx.id) - packetResponse, ok := <-msgCtx.responses + case packetResponse, ok := <-msgCtx.responses: if !ok { err := NewError(ErrorNetwork, errors.New("ldap: response channel closed")) r.ch <- &SearchSingleResult{Error: err} From 41d400950f1425475e1c10d848b999c44c57d76b Mon Sep 17 00:00:00 2001 From: Tetsuya Morimoto Date: Mon, 1 Apr 2024 17:27:13 +0900 Subject: [PATCH 2/2] Add debug print for response --- response.go | 1 + v3/response.go | 1 + 2 files changed, 2 insertions(+) diff --git a/response.go b/response.go index dbb36c2b..0eae1001 100644 --- a/response.go +++ b/response.go @@ -98,6 +98,7 @@ func (r *searchResponse) start(ctx context.Context, searchRequest *SearchRequest foundSearchSingleResultDone := false for !foundSearchSingleResultDone { + r.conn.Debug.Printf("%d: waiting for response", msgCtx.id) select { case <-ctx.Done(): r.conn.Debug.Printf("%d: %s", msgCtx.id, ctx.Err().Error()) diff --git a/v3/response.go b/v3/response.go index dbb36c2b..0eae1001 100644 --- a/v3/response.go +++ b/v3/response.go @@ -98,6 +98,7 @@ func (r *searchResponse) start(ctx context.Context, searchRequest *SearchRequest foundSearchSingleResultDone := false for !foundSearchSingleResultDone { + r.conn.Debug.Printf("%d: waiting for response", msgCtx.id) select { case <-ctx.Done(): r.conn.Debug.Printf("%d: %s", msgCtx.id, ctx.Err().Error())