mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
inlet/bmp: trust the metrics to check if socket is closed
This is pointless to try to make Write() error on loopback. Maybe we need 16KB, maybe not. Assume that if we say it is closed, then it is.
This commit is contained in:
@@ -109,10 +109,10 @@ func TestBMP(t *testing.T) {
|
||||
if diff := helpers.Diff(gotMetrics, expectedMetrics); diff != "" {
|
||||
t.Errorf("Metrics (-got, +want):\n%s", diff)
|
||||
}
|
||||
for i := 0; i < 100; i++ {
|
||||
for i := 0; ; i++ {
|
||||
if _, err := conn.Write([]byte{1}); err != nil {
|
||||
break
|
||||
} else if err == nil && i == 99 {
|
||||
} else if i >= 200 {
|
||||
t.Fatal("Write() did not error while connection should be closed")
|
||||
}
|
||||
time.Sleep(5 * time.Millisecond)
|
||||
|
||||
@@ -34,8 +34,7 @@ func (c *Component) serveConnection(conn *net.TCPConn) error {
|
||||
case <-c.t.Dying():
|
||||
// No need to clean up
|
||||
}
|
||||
conn.CloseWrite()
|
||||
conn.CloseRead()
|
||||
conn.Close()
|
||||
c.metrics.closedConnections.WithLabelValues(exporterStr).Inc()
|
||||
return nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user