From 1e620427bd01b1e897c57752359f7dbb28e34bff Mon Sep 17 00:00:00 2001 From: Mathias Hall-Andersen Date: Sat, 1 Jul 2017 23:29:22 +0200 Subject: Handshake negotiation functioning --- src/misc.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/misc.go') diff --git a/src/misc.go b/src/misc.go index 2bcb148..dd4fa63 100644 --- a/src/misc.go +++ b/src/misc.go @@ -1,5 +1,9 @@ package main +import ( + "time" +) + func min(a uint, b uint) uint { if a > b { return b @@ -13,3 +17,18 @@ func sendSignal(c chan struct{}) { default: } } + +func stopTimer(timer *time.Timer) { + if !timer.Stop() { + select { + case <-timer.C: + default: + } + } +} + +func stoppedTimer() *time.Timer { + timer := time.NewTimer(time.Hour) + stopTimer(timer) + return timer +} -- cgit v1.2.3