fix(oohelperd): use throw-away HTTPClient, Dialer, Resolver (#833)
This diff modifies the implementation of oohelperd in the master branch to always use throw-away HTTPClient, Dialer, and Resolver. The rationale of this change is to ensure we're not hitting limits of the HTTPClient regarding the max number of connections per host. This issue is described at https://github.com/ooni/probe/issues/2182. While there, it feels more correct to use throw-away Dialer and Resolver. We have a different patch for the release/3.15 branch because of netx-related refactorings: https://github.com/ooni/probe-cli/pull/832.
This commit is contained in:
parent
59410edba9
commit
a4d17085f5
9 changed files with 87 additions and 60 deletions
|
|
@ -20,16 +20,18 @@ type TCPResultPair struct {
|
|||
|
||||
// TCPConfig configures the TCP connect check.
|
||||
type TCPConfig struct {
|
||||
Dialer model.Dialer
|
||||
Endpoint string
|
||||
Out chan TCPResultPair
|
||||
Wg *sync.WaitGroup
|
||||
Endpoint string
|
||||
NewDialer func() model.Dialer
|
||||
Out chan TCPResultPair
|
||||
Wg *sync.WaitGroup
|
||||
}
|
||||
|
||||
// TCPDo performs the TCP check.
|
||||
func TCPDo(ctx context.Context, config *TCPConfig) {
|
||||
defer config.Wg.Done()
|
||||
conn, err := config.Dialer.DialContext(ctx, "tcp", config.Endpoint)
|
||||
dialer := config.NewDialer()
|
||||
defer dialer.CloseIdleConnections()
|
||||
conn, err := dialer.DialContext(ctx, "tcp", config.Endpoint)
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue