Skip to content

Commit

Permalink
pull the begin nanotime at EncodedFieldSection construction
Browse files Browse the repository at this point in the history
Signed-off-by: Ludovic Orban <[email protected]>
  • Loading branch information
lorban committed Nov 23, 2023
1 parent 61c5556 commit c10f66c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class MessageParser
private BodyParser unknownBodyParser;
private State state = State.HEADER;
private long beginNanoTime;
private boolean nanoTimeStored;
private boolean beginNanoTimeStored;
protected boolean dataMode;

public MessageParser(ParserListener listener, QpackDecoder decoder, long streamId, BooleanSupplier isLast)
Expand All @@ -70,15 +70,15 @@ private void reset()
{
headerParser.reset();
state = State.HEADER;
nanoTimeStored = false;
beginNanoTimeStored = false;
}

private void storeBeginNanoTime()
{
if (!nanoTimeStored)
if (!beginNanoTimeStored)
{
beginNanoTime = NanoTime.now();
nanoTimeStored = true;
beginNanoTimeStored = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public boolean decode(long streamId, ByteBuffer buffer, Handler handler) throws
{
// Parse the buffer into an Encoded Field Section.
int base = signBit ? requiredInsertCount - deltaBase - 1 : requiredInsertCount + deltaBase;
EncodedFieldSection encodedFieldSection = new EncodedFieldSection(streamId, handler, requiredInsertCount, base, buffer, _beginNanoTimeSupplier);
EncodedFieldSection encodedFieldSection = new EncodedFieldSection(streamId, handler, requiredInsertCount, base, buffer, _beginNanoTimeSupplier.getAsLong());

// Decode it straight away if we can, otherwise add it to the list of EncodedFieldSections.
if (requiredInsertCount <= insertCount)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.function.LongSupplier;

import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.MetaData;
Expand Down Expand Up @@ -45,15 +44,15 @@ public class EncodedFieldSection
private final int _requiredInsertCount;
private final int _base;
private final QpackDecoder.Handler _handler;
private final LongSupplier _beginNanoTimeSupplier;
private final long _beginNanoTime;

public EncodedFieldSection(long streamId, QpackDecoder.Handler handler, int requiredInsertCount, int base, ByteBuffer content, LongSupplier beginNanoTimeSupplier) throws QpackException
public EncodedFieldSection(long streamId, QpackDecoder.Handler handler, int requiredInsertCount, int base, ByteBuffer content, long beginNanoTime) throws QpackException
{
_streamId = streamId;
_requiredInsertCount = requiredInsertCount;
_base = base;
_handler = handler;
_beginNanoTimeSupplier = beginNanoTimeSupplier;
_beginNanoTime = beginNanoTime;

try
{
Expand Down Expand Up @@ -107,7 +106,7 @@ public MetaData decode(QpackContext context, int maxHeaderSize) throws QpackExce
HttpField decodedField = encodedField.decode(context);
metaDataBuilder.emit(decodedField);
}
metaDataBuilder.setBeginNanoTime(_beginNanoTimeSupplier.getAsLong());
metaDataBuilder.setBeginNanoTime(_beginNanoTime);
return metaDataBuilder.build();
}

Expand Down

0 comments on commit c10f66c

Please sign in to comment.