Skip to content

Commit 869642d

Browse files
committed
ethrpc: use mutex instead of atomic value
1 parent 1590ac3 commit 869642d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ethrpc/ethrpc.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,16 @@ type StreamUnsubscriber interface {
111111

112112
func (s *Provider) SetHTTPClient(client httpClient) {
113113
s.httpClientMu.Lock()
114-
defer s.httpClientMu.Unlock()
115114
s.httpClient = client
115+
s.httpClientMu.Unlock()
116116
}
117117

118118
func (p *Provider) getHTTPClient() httpClient {
119119
p.httpClientMu.RLock()
120-
defer p.httpClientMu.RUnlock()
121-
return p.httpClient
120+
httpClient := p.httpClient
121+
p.httpClientMu.RUnlock()
122+
123+
return httpClient
122124
}
123125

124126
func (p *Provider) StrictnessLevel() StrictnessLevel {

0 commit comments

Comments
 (0)