-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve handling of connection read errors (#66)
If the reader() goroutine encounters an unexpected error when reading a packet a series of unwinding takes place: - The reader() goroutine shuts down. A deferred function runs which closes the connection. - Close() sends a MessageQuit message to the processMessages() goroutine. - The processMessages() goroutine shuts down. A deferred function runs which closes the results channels for any pending requests. - These pending request handlers receive a nil *PacketResponse because their response channel has been closed. They then return a not-very-helpful error string: "ldap: channel closed". This patch updates the reader() goroutine to set a closeErr value on the conn when it encounters an unexpected error reading a packet from the server. The processMessages() deferred function checks for this closeErr when it is shutting down due to the connection closing and sends this error in the *PacketResponse values to the pending request handlers *before* closing those results channels. This allows for the error which caused the shutdown to be bubbled up to all pending request calls. Docker-DCO-1.1-Signed-off-by: Josh Hawn <[email protected]> (github: jlhawn)
- Loading branch information
Showing
2 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters