mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
workaround to random timeouts
This commit is contained in:
parent
5d323861f0
commit
6469e39ff1
2 changed files with 6 additions and 7 deletions
|
@ -48,13 +48,12 @@ func PutBytes(bs []byte) {
|
|||
|
||||
// This is a workaround to go's broken timer implementation
|
||||
func TimerStop(t *time.Timer) bool {
|
||||
if !t.Stop() {
|
||||
select {
|
||||
case <-t.C:
|
||||
default:
|
||||
}
|
||||
stopped := t.Stop()
|
||||
select {
|
||||
case <-t.C:
|
||||
default:
|
||||
}
|
||||
return true
|
||||
return stopped
|
||||
}
|
||||
|
||||
// Run a blocking function with a timeout.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue