Skip to content

Commit

Permalink
Add debug logging for client connection accounting
Browse files Browse the repository at this point in the history
  • Loading branch information
IngmarStein committed May 24, 2024
1 parent 053534c commit b582e51
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/multiplexer/multiplexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ L:

func (mux *Multiplexer) handleConnection(conn net.Conn, sender chan<- *reqContainer) {
defer func(c net.Conn) {
if logrus.IsLevelEnabled(logrus.DebugLevel) {
logrus.Debugf("Closing client connecion: %v", c.RemoteAddr())
}
err := c.Close()
sender <- &reqContainer{typ: Disconnection}
if err != nil {
Expand All @@ -115,7 +118,7 @@ func (mux *Multiplexer) handleConnection(conn net.Conn, sender chan<- *reqContai
}

if logrus.IsLevelEnabled(logrus.DebugLevel) {
logrus.Debug("Message from Client...")
logrus.Debug("Message from client...")
spew.Dump(msg)
}

Expand Down Expand Up @@ -166,10 +169,17 @@ func (mux *Multiplexer) targetConnLoop(requestQueue <-chan *reqContainer) {
switch container.typ {
case Connection:
clients++
if logrus.IsLevelEnabled(logrus.DebugLevel) {
logrus.Debugf("Connected clients: %d", clients)
}
continue
case Disconnection:
clients--
if logrus.IsLevelEnabled(logrus.DebugLevel) {
logrus.Debugf("Connected clients: %d", clients)
}
if clients == 0 && conn != nil {
logrus.Info("closing target connection")
err := conn.Close()
if err != nil {
logrus.Error(err)
Expand Down

0 comments on commit b582e51

Please sign in to comment.