Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
This PR resolves an issue in the Start function of the monitoring package, specifically concerning how the errCh channel could become blocked. The PR also addresses an array index out-of-bounds issue in the processIndicationFormat1 function.
Issue Details:
* Blocked errCh Channel
In the original implementation, the errCh channel was used to handle errors generated by both the m.streamReader.Recv(ctx) and m.processIndication(ctx, indMsg, m.measurements, m.nodeID) methods. However, the channel can lead to a blocking issue:
To illustrate, when m.processIndication first produces an error, this error is consumed by the parent Start function. As a result, the Start function returns, eliminating the only consumer for the errCh channel. Consequently, when a second error is posted to errCh, the send operation gets indefinitely blocked. This blockage prevents the associated indication processing goroutine from processing subsequent indication messages.
* Array Index Out-of-Bounds in processIndicationFormat1
The processIndicationFormat1 function had the potential to cause a panic due to array index out-of-bounds. This happened when measInfoList was smaller in size than meadDataRecords. A simple check is added to prevent the panic.
Please let me know if these fixes are reasonable or if any further modifications are required.