Skip to content

Commit

Permalink
fix(plc4go/spi): avoid unnecessary read on DefaultCodec shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Jun 20, 2023
1 parent 8535bef commit fe99681
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions plc4go/spi/default/DefaultCodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,12 @@ mainLoop:
{
syncer := make(chan struct{})
go func() {
defer close(syncer)
if !m.running.Load() {
err = errors.New("not running")
return
}
message, err = m.Receive()
close(syncer)
}()
timeoutTimer := time.NewTimer(m.receiveTimeout)
select {
Expand All @@ -339,7 +343,6 @@ mainLoop:
workerLog.Error().Msgf("receive timeout after %s", m.receiveTimeout)
continue mainLoop
}

}
if err != nil {
workerLog.Error().Err(err).Msg("got an error reading from transport")
Expand Down
3 changes: 2 additions & 1 deletion plc4go/spi/transports/TransportInstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ package transports
import (
"context"
"fmt"
"io"
)

type TransportInstance interface {
fmt.Stringer
io.Closer
Connect() error
ConnectWithContext(ctx context.Context) error
Close() error

IsConnected() bool

Expand Down

0 comments on commit fe99681

Please sign in to comment.