summaryrefslogtreecommitdiffhomepage
path: root/src/misc.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-07-01 23:29:22 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-07-01 23:29:22 +0200
commit1e620427bd01b1e897c57752359f7dbb28e34bff (patch)
treef525ee38fec7826b07060271dcc06601f992612d /src/misc.go
parenta4cc0a30faa64c2c293c589d98e4ba7390e56fda (diff)
Handshake negotiation functioning
Diffstat (limited to 'src/misc.go')
-rw-r--r--src/misc.go19
1 files changed, 19 insertions, 0 deletions
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
+}