From 10f51ef10ab5d4a440e20c1c8e7c203b3a16be85 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sun, 26 Mar 2017 16:16:39 -0700 Subject: [PATCH] tun2: don't goroutine it up, not fam --- lib/tun2/server.go | 52 ++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/lib/tun2/server.go b/lib/tun2/server.go index 7893735..5e70529 100644 --- a/lib/tun2/server.go +++ b/lib/tun2/server.go @@ -158,42 +158,36 @@ func (s *Server) ListenAndServe() error { s.connlock.Lock() for _, c := range s.conns { - go func() { - req, err := http.NewRequest("GET", "http://backend/health", nil) - if err != nil { - panic(err) - } + req, err := http.NewRequest("GET", "http://backend/health", nil) + if err != nil { + panic(err) + } - ln.Log(c.F(), ln.F{ - "action": "sending_ping", - }) + stream, err := c.session.OpenStream() + if err != nil { + ln.Error(err, c.F()) - stream, err := c.session.OpenStream() - if err != nil { - ln.Error(err) + c.cancel() + } - c.cancel() - } + err = req.Write(stream) + if err != nil { + ln.Error(err, c.F()) - err = req.Write(stream) - if err != nil { - ln.Error(err) + c.cancel() + } - c.cancel() - } + _, err = stream.Read(make([]byte, 30)) + if err != nil { + ln.Error(err, c.F()) + c.cancel() + } - _, err = stream.Read(make([]byte, 30)) - if err != nil { - ln.Error(err) - c.cancel() - } + stream.Close() - stream.Close() - - ln.Log(ln.F{ - "action": "ping_health_is_good", - }, c.F()) - }() + ln.Log(ln.F{ + "action": "ping_health_is_good", + }, c.F()) } s.connlock.Unlock()