Skip to content

Commit

Permalink
Reduce and reorder sync section in blockwise layer.
Browse files Browse the repository at this point in the history
Move clearBlock2Status out of the synchronized section of the
BlockwiseStatus.
ClearBlock2Status synchronizes on block2Transfers and must be called
within a synchronized section of a BlockwiseStatus.

Signed-off-by: Achim Kraus <achim.kraus@bosch.io>
  • Loading branch information
Achim Kraus committed Jan 4, 2021
1 parent 14e0d3e commit c7c0697
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,20 +522,24 @@ private void handleInboundRequestForNextBlock(final Exchange exchange, final Req
final KeyUri key, final Block2BlockwiseStatus status) {

Response block;
boolean complete;
synchronized (status) {

BlockOption block2 = request.getOptions().getBlock2();
block = status.getNextResponseBlock(block2);
if (status.isComplete()) {
// clean up blockwise status
LOGGER.debug("peer has requested last block of blockwise transfer: {}", status);
clearBlock2Status(key, status);
} else {
complete = status.isComplete();
if (!complete) {
prepareBlock2Cleanup(status, key);
LOGGER.debug("peer has requested intermediary block of blockwise transfer: {}", status);
}
}

if (complete) {
// clean up blockwise status
LOGGER.debug("peer has requested last block of blockwise transfer: {}", status);
clearBlock2Status(key, status);
}

exchange.setCurrentResponse(block);
lower().sendResponse(exchange, block);
}
Expand Down

0 comments on commit c7c0697

Please sign in to comment.