summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKorhonen Sami (Samlink) <k847259@ubuntu.saminet.fi>2020-07-09 15:11:44 +0300
committerMatthew Heon <matthew.heon@pm.me>2020-07-22 14:45:28 -0400
commit6128cbec04fd80b62a9afe75adabd2acfd968909 (patch)
treecf2ddcd42a5c014ef9dd9b5a19867ead202ac591
parent1fb32b9b2f1196f02fdd0aba8f55e18684e9e932 (diff)
downloadpodman-6128cbec04fd80b62a9afe75adabd2acfd968909.tar.gz
podman-6128cbec04fd80b62a9afe75adabd2acfd968909.tar.bz2
podman-6128cbec04fd80b62a9afe75adabd2acfd968909.zip
Remove hijacked connections from active connections list
StateHijacked is a terminal state. If hijacked connection is registered as an active connection, connection will never be unregistered. This causes two issues First issue is that active connection counters are off. Second issue is a resource leak caused by connection object that is stored to a map. After this patch hijacked connections are no longer visible in counters. If a counter for hijacked connections is required, podman must track connections returned by Hijacker.Hijack() It might make sense to develop abstraction layer for hijacking - and move all hijacking related code to a separate package. Hijacking code is prone to resource leaks and it should be thoroughly tested. Signed-off-by: Sami Korhonen <skorhone@gmail.com>
-rw-r--r--pkg/api/server/server.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/pkg/api/server/server.go b/pkg/api/server/server.go
index 8af6d3186..f5b17ab68 100644
--- a/pkg/api/server/server.go
+++ b/pkg/api/server/server.go
@@ -255,14 +255,14 @@ func (t *IdleTracker) ConnState(conn net.Conn, state http.ConnState) {
oldActive := len(t.active)
logrus.Debugf("IdleTracker %p:%v %d/%d connection(s)", conn, state, t.ActiveConnections(), t.TotalConnections())
switch state {
- case http.StateNew, http.StateActive, http.StateHijacked:
+ case http.StateNew, http.StateActive:
t.active[conn] = struct{}{}
// stop the timer if we transitioned from idle
if oldActive == 0 {
t.timer.Stop()
}
t.total++
- case http.StateIdle, http.StateClosed:
+ case http.StateIdle, http.StateClosed, http.StateHijacked:
delete(t.active, conn)
// Restart the timer if we've become idle
if oldActive > 0 && len(t.active) == 0 {