Skip to content

Commit

Permalink
fix(plc4go/cbus): concurrency might lead to a incomplete reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Apr 24, 2023
1 parent d4a37ea commit fb7ff11
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions plc4go/internal/cbus/Browser.go
Expand Up @@ -213,23 +213,6 @@ func (m Browser) getInstalledUnitAddressBytes(ctx context.Context) (map[byte]any
} else {
blockStart = int(blockStartValue.GetByte())
}
switch blockStart {
case 88:
select {
case blockOffset88ReceivedChan <- true:
default:
}
case 176:
select {
case blockOffset176ReceivedChan <- true:
default:
}
case 0:
select {
case blockOffset0ReceivedChan <- true:
default:
}
}

if plcListValue := rootStruct["values"]; plcListValue == nil || !plcListValue.IsList() {
log.Warn().Msgf("Ignoring %v should contain a values tag of type list", rootStruct)
Expand All @@ -252,6 +235,24 @@ func (m Browser) getInstalledUnitAddressBytes(ctx context.Context) (map[byte]any
}
}
}
// We notify here so we don't exit to early
switch blockStart {
case 88:
select {
case blockOffset88ReceivedChan <- true:
default:
}
case 176:
select {
case blockOffset176ReceivedChan <- true:
default:
}
case 0:
select {
case blockOffset0ReceivedChan <- true:
default:
}
}
})
defer plcConsumerRegistration.Unregister()

Expand Down

0 comments on commit fb7ff11

Please sign in to comment.