Skip to content

Commit

Permalink
Adds log to readLoop just like write loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ackleymi committed May 17, 2024
1 parent fd466b7 commit b8c5ddc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func (a *Acceptor) handleConnection(netConn net.Conn) {

go func() {
msgIn <- fixIn{msgBytes, parser.lastRead}
readLoop(parser, msgIn)
readLoop(parser, msgIn, a.globalLog)
}()

writeLoop(netConn, msgOut, a.globalLog)
Expand Down
3 changes: 2 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ func writeLoop(connection io.Writer, messageOut chan []byte, log Log) {
}
}

func readLoop(parser *parser, msgIn chan fixIn) {
func readLoop(parser *parser, msgIn chan fixIn, log Log) {
defer close(msgIn)

for {
msg, err := parser.ReadMessage()
if err != nil {
log.OnEvent(err.Error())
return
}
msgIn <- fixIn{msg, parser.lastRead}
Expand Down
2 changes: 1 addition & 1 deletion initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (i *Initiator) handleConnection(session *session, tlsConfig *tls.Config, di
goto reconnect
}

go readLoop(newParser(bufio.NewReader(netConn)), msgIn)
go readLoop(newParser(bufio.NewReader(netConn)), msgIn, session.log)
disconnected = make(chan interface{})
go func() {
writeLoop(netConn, msgOut, session.log)
Expand Down

0 comments on commit b8c5ddc

Please sign in to comment.