Skip to content

Commit

Permalink
Added read deadline during ping to handle paused servers (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg authored Sep 29, 2021
1 parent 95a4a4c commit 9baeff2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pinger.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ func (p *mcPinger) ping() (*ServerInfo, error) {
return nil, err
}

if p.Timeout > 0 {
// When a remote process is bound, but paused, the connect succeeds without context timeout;
// however, the response packet just never comes back.
_ = conn.SetReadDeadline(time.Now().Add(p.Timeout))
}
res, err := p.readPacket(rd)

if err != nil {
Expand Down

0 comments on commit 9baeff2

Please sign in to comment.