Skip to content

Commit

Permalink
Capture correct errors in CheckRetray wrapper
Browse files Browse the repository at this point in the history
Test closing idle connections to see if affects memory
  • Loading branch information
jwlv committed Nov 25, 2024
1 parent d5093ef commit 0ec5fe6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions pkg/trs_http_api/trshttp_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ func (c *trsRoundTripper) trsCheckRetry(ctx context.Context, resp *http.Response
}

// If none of the above, delegate retry check to retryablehttp
shouldRetry, err := retryablehttp.DefaultRetryPolicy(ctx, resp, err)
shouldRetry, defaultRPErr := retryablehttp.DefaultRetryPolicy(ctx, resp, err)

//wrapperLogger.Errorf("trsCheckRetry: DefaultRetryPolicy: shouldRetry=%v", shouldRetry)

Expand Down Expand Up @@ -411,7 +411,7 @@ func (c *trsRoundTripper) trsCheckRetry(ctx context.Context, resp *http.Response
}
}

return shouldRetry, err
return shouldRetry, defaultRPErr
}

// Create and configure a new client transport for use with HTTP clients.
Expand Down Expand Up @@ -622,7 +622,8 @@ func ExecuteTask(tloc *TRSHTTPLocal, tct taskChannelTuple) {
}

// TODO: Consider cancelling the context for this task here instead of
// leaving it up to the caller
// leaving it up to the caller - Would have to read and close response
// here as well

tct.taskListChannel <- tct.task
}
Expand Down Expand Up @@ -767,6 +768,16 @@ func (tloc *TRSHTTPLocal) Close(taskList *[]HttpTask) {
tloc.taskMutex.Unlock()

}
// See if this helps memory leak
for k := range tloc.clientMap {
if (tloc.clientMap[k].insecure != nil) {
tloc.clientMap[k].insecure.HTTPClient.CloseIdleConnections()
}
if (tloc.clientMap[k].secure != nil) {
tloc.clientMap[k].secure.HTTPClient.CloseIdleConnections()
}
}

tloc.Logger.Tracef("Close() completed")
}

Expand Down

0 comments on commit 0ec5fe6

Please sign in to comment.