-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
searchAsync checks cancelled context only after receiving an ldap response #495
Comments
Until last week, I used the err := c.conn.Close() This issue might be related to what I encountered. I'm going to investigate today and report them after that. |
I added the select statement as below PR. I indicate this as just non-blocking select, so I also think the suggested statement is better. case packetResponse, ok := <-msgCtx.responses: |
About my comment #495 (comment) , I found another issue between an application that uses this library and this library. Because |
Fixed by PR #496 |
That's been quick, thanks a lot 👍 |
…chAsync() (go-ldap#496) * Refactor the context handling with receiving an ldap response in searchAsync() go-ldap#495 * Add debug print for response
I have a use case with long lasting ldap requests to retrieve many single entries from a ldap server.
To stay responsive for application shutdown, ... during such a query, searchAsync is used with a Context, that will be cancelled once the query has to be terminated early.
This works in principle, but the ldap server also shows the behaviour that it can take a long period of time (minutes) between the returned sinlge search results.
Unfortunately, cancelling the async search is also blocked during such periods, resp. the cancelled context will not be recognized until some event from the server side occurs.
Regarding the implementation in response.go, this is probably caused by waiting for new responses via the default case in the according select statement:
So, the check for ctx.Done() only happens between blocking reads on msgCtx.responses.
I guess, handling new repsonses in a distinct case would solve this problem:
As far as I can see, there is no reason against using a specific case, but I'm far from having sufficient overview of the code.
Could someone explain, whether there is a need for the default case?
Many thanks in advance.
The text was updated successfully, but these errors were encountered: