Skip to content

Commit

Permalink
Fixed the use of the provided fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
NErinola committed Jul 7, 2023
1 parent aaf0042 commit 7b25103
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,16 @@ public LayerProcessingResult<DtlsHandshakeMessageFragment> sendData(
fragments = getEnoughFragments(context, data.length);
} else {
// use the provided fragments
fragments.add(getUnprocessedConfiguredContainers().get(0));
if (context.getConfig().isCreateFragmentsDynamically()) {
fragments.addAll(
getEnoughFragments(
context,
data.length - fragments.get(0).getMaxFragmentLengthConfig()));
int dataToBeSent = data.length;
List<DtlsHandshakeMessageFragment> givenFragments =
getUnprocessedConfiguredContainers();
while (dataToBeSent > 0 && givenFragments.size() > 0) {
DtlsHandshakeMessageFragment nextFragment = givenFragments.remove(0);
fragments.add(nextFragment);
dataToBeSent -= nextFragment.getMaxFragmentLengthConfig();
}
if (dataToBeSent > 0 && context.getConfig().isCreateFragmentsDynamically()) {
fragments.addAll(getEnoughFragments(context, dataToBeSent));
}
}
fragments =
Expand Down

0 comments on commit 7b25103

Please sign in to comment.