Fix upstream gauge metric
It wasn't decremented on error. While at it, increment it when connecting to the upstream network.
This commit is contained in:
parent
73287f242e
commit
d11216917b
6
user.go
6
user.go
@ -202,10 +202,13 @@ func (net *network) run() {
|
||||
}
|
||||
lastTry = time.Now()
|
||||
|
||||
net.user.srv.metrics.upstreams.Add(1)
|
||||
|
||||
uc, err := connectToUpstream(context.TODO(), net)
|
||||
if err != nil {
|
||||
net.logger.Printf("failed to connect to upstream server %q: %v", net.Addr, err)
|
||||
net.user.events <- eventUpstreamConnectionError{net, fmt.Errorf("failed to connect: %v", err)}
|
||||
net.user.srv.metrics.upstreams.Add(-1)
|
||||
continue
|
||||
}
|
||||
|
||||
@ -213,8 +216,6 @@ func (net *network) run() {
|
||||
net.user.srv.Identd.Store(uc.RemoteAddr().String(), uc.LocalAddr().String(), userIdent(&net.user.User))
|
||||
}
|
||||
|
||||
net.user.srv.metrics.upstreams.Add(1)
|
||||
|
||||
uc.register()
|
||||
if err := uc.runUntilRegistered(); err != nil {
|
||||
text := err.Error()
|
||||
@ -224,6 +225,7 @@ func (net *network) run() {
|
||||
uc.logger.Printf("failed to register: %v", text)
|
||||
net.user.events <- eventUpstreamConnectionError{net, fmt.Errorf("failed to register: %v", text)}
|
||||
uc.Close()
|
||||
net.user.srv.metrics.upstreams.Add(-1)
|
||||
continue
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user