tun2: don't goroutine it up, not fam

This commit is contained in:
Cadey Ratio 2017-03-26 16:16:39 -07:00
parent 46b29ea22d
commit 10f51ef10a
1 changed files with 23 additions and 29 deletions

View File

@ -158,42 +158,36 @@ func (s *Server) ListenAndServe() error {
s.connlock.Lock() s.connlock.Lock()
for _, c := range s.conns { for _, c := range s.conns {
go func() { req, err := http.NewRequest("GET", "http://backend/health", nil)
req, err := http.NewRequest("GET", "http://backend/health", nil) if err != nil {
if err != nil { panic(err)
panic(err) }
}
ln.Log(c.F(), ln.F{ stream, err := c.session.OpenStream()
"action": "sending_ping", if err != nil {
}) ln.Error(err, c.F())
stream, err := c.session.OpenStream() c.cancel()
if err != nil { }
ln.Error(err)
c.cancel() err = req.Write(stream)
} if err != nil {
ln.Error(err, c.F())
err = req.Write(stream) c.cancel()
if err != nil { }
ln.Error(err)
c.cancel() _, err = stream.Read(make([]byte, 30))
} if err != nil {
ln.Error(err, c.F())
c.cancel()
}
_, err = stream.Read(make([]byte, 30)) stream.Close()
if err != nil {
ln.Error(err)
c.cancel()
}
stream.Close() ln.Log(ln.F{
"action": "ping_health_is_good",
ln.Log(ln.F{ }, c.F())
"action": "ping_health_is_good",
}, c.F())
}()
} }
s.connlock.Unlock() s.connlock.Unlock()