Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
close chan struct{}
rtoRate time.Duration
maxAttempts int32
closed bool
closed atomic.Bool
closeConn bool // should call c.Close() while closing
wg sync.WaitGroup
clock Clock
Expand Down Expand Up @@ -346,11 +346,11 @@
//
// Could return ErrClientClosed, ErrTransactionExists.
func (c *Client) start(t *clientTransaction) error {
c.mux.Lock()
defer c.mux.Unlock()
if c.closed {
if c.closed.Load() {

Check warning on line 349 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L349

Added line #L349 was not covered by tests
return ErrClientClosed
}
c.mux.Lock()
defer c.mux.Unlock()

Check warning on line 353 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L352-L353

Added lines #L352 - L353 were not covered by tests
_, exists := c.t[t.id]
if exists {
return ErrTransactionExists
Expand Down Expand Up @@ -486,14 +486,10 @@
if err := c.checkInit(); err != nil {
return err
}
c.mux.Lock()
if c.closed {
c.mux.Unlock()

if c.closed.Load() {

Check warning on line 489 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L489

Added line #L489 was not covered by tests
return ErrClientClosed
}
c.closed = true
c.mux.Unlock()
c.closed.Store(true)

Check warning on line 492 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L492

Added line #L492 was not covered by tests
if closeErr := c.collector.Close(); closeErr != nil {
return closeErr
}
Expand Down Expand Up @@ -624,12 +620,10 @@
}

func (c *Client) handleAgentCallback(event Event) { //nolint:cyclop
c.mux.Lock()
if c.closed {
c.mux.Unlock()

if c.closed.Load() {

Check warning on line 623 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L623

Added line #L623 was not covered by tests
return
}
c.mux.Lock()

Check warning on line 626 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L626

Added line #L626 was not covered by tests
transaction, found := c.t[event.TransactionID]
if found {
delete(c.t, transaction.id)
Expand Down Expand Up @@ -705,10 +699,7 @@
if err := c.checkInit(); err != nil {
return err
}
c.mux.RLock()
closed := c.closed
c.mux.RUnlock()
if closed {
if c.closed.Load() {

Check warning on line 702 in client.go

View check run for this annotation

Codecov / codecov/patch

client.go#L702

Added line #L702 was not covered by tests
return ErrClientClosed
}
if handler != nil {
Expand Down
Loading