Improve error handling

This commit is contained in:
Daniel
2020-07-21 14:59:14 +02:00
parent 7b40e83aec
commit dda7cdf7d0
3 changed files with 29 additions and 137 deletions

View File

@@ -145,7 +145,6 @@ func (tr *TCPResolver) Query(ctx context.Context, q *Query) (*RRCache, error) {
select {
case reply = <-inFlight.Response:
case <-time.After(defaultRequestTimeout):
tr.ReportFailure()
return nil, ErrTimeout
}
@@ -180,6 +179,14 @@ func (tr *TCPResolver) startClient() {
func (mgr *tcpResolverConnMgr) run(workerCtx context.Context) error {
// connection lifecycle loop
for {
// check if we are shutting down
select {
case <-workerCtx.Done():
mgr.shutdown()
return nil
default:
}
// check if we are failing
if mgr.failCnt >= FailThreshold || mgr.tr.IsFailing() {
mgr.shutdown()