Skip to content

Commit

Permalink
Merge pull request #5 from appuio/fix/inflight-race-condition
Browse files Browse the repository at this point in the history
Fix race condition in ICMP pinger
  • Loading branch information
glrf authored Sep 12, 2022
2 parents 0644abc + b7cf530 commit 4a17c9c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ping/pinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,11 @@ func (p *pinger) ping() error {
return fmt.Errorf("Failed to marshal ICMP packet: %w", err)
}

p.inflight.Store(p.seq, sent)
if _, err := p.conn.WriteTo(msgB, &p.addr); err != nil {
p.inflight.Delete(p.seq)
return fmt.Errorf("Failed to send ICMP packet: %w", err)
}
p.inflight.Store(p.seq, sent)
p.seq = p.seq + 1
return nil
}
Expand Down

0 comments on commit 4a17c9c

Please sign in to comment.