Skip to content

Commit

Permalink
move initializing the buffered reader out of the loop (#440)
Browse files Browse the repository at this point in the history
having it inside the loop destroys the reader after every iteration and it may contain
bytes at that point
  • Loading branch information
dmissmann authored Aug 2, 2024
1 parent 029c608 commit a1a147e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ios/dtx_codec/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ func (dtxConn *Connection) Send(message []byte) error {

// reader reads messages from the byte stream and dispatches them to the right channel when they are decoded.
func reader(dtxConn *Connection) {
reader := bufio.NewReader(dtxConn.deviceConnection.Reader())
for {
reader := bufio.NewReader(dtxConn.deviceConnection.Reader())
msg, err := ReadMessage(reader)
if err != nil {
defer dtxConn.close(err)
Expand Down

0 comments on commit a1a147e

Please sign in to comment.