Skip to content

Commit

Permalink
Add a comment to clarify the code (java-native-access#486)
Browse files Browse the repository at this point in the history
Motivation:

It was not clear why we did return 8 in some cases.

Modifications:

Add comment

Result:

Easier to understand code
  • Loading branch information
normanmaurer authored Mar 9, 2023
1 parent 0fdf82d commit 1ab1e08
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,10 @@ private static boolean isSendWindowUsed(int maxDatagramSize, int len) {
private static int calculateSendBufferLength(long connAddr, int maxDatagramSize) {
int len = Math.min(maxDatagramSize, Quiche.quiche_conn_send_quantum(connAddr));
if (len <= 0) {
// If there is no room left we just return some small number to reduce the risk of packet drop
// while still be able to attach the listener to the write future.
// We use the value of 8 because such an allocation will be cheap to serve from the
// PooledByteBufAllocator while still serve our need.
return 8;
}
return len;
Expand Down

0 comments on commit 1ab1e08

Please sign in to comment.