forked from quic-go/quic-go
connection: refactor handling of frames when tracing
This commit is contained in:
@@ -1261,7 +1261,11 @@ func (s *connection) handleFrames(
|
|||||||
) (isAckEliciting bool, _ error) {
|
) (isAckEliciting bool, _ error) {
|
||||||
// Only used for tracing.
|
// Only used for tracing.
|
||||||
// If we're not tracing, this slice will always remain empty.
|
// If we're not tracing, this slice will always remain empty.
|
||||||
var frames []wire.Frame
|
var frames []logging.Frame
|
||||||
|
if log != nil {
|
||||||
|
frames = make([]logging.Frame, 0, 4)
|
||||||
|
}
|
||||||
|
var handleErr error
|
||||||
for len(data) > 0 {
|
for len(data) > 0 {
|
||||||
l, frame, err := s.frameParser.ParseNext(data, encLevel, s.version)
|
l, frame, err := s.frameParser.ParseNext(data, encLevel, s.version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1274,27 +1278,27 @@ func (s *connection) handleFrames(
|
|||||||
if ackhandler.IsFrameAckEliciting(frame) {
|
if ackhandler.IsFrameAckEliciting(frame) {
|
||||||
isAckEliciting = true
|
isAckEliciting = true
|
||||||
}
|
}
|
||||||
// Only process frames now if we're not logging.
|
if log != nil {
|
||||||
// If we're logging, we need to make sure that the packet_received event is logged first.
|
frames = append(frames, logutils.ConvertFrame(frame))
|
||||||
if log == nil {
|
// An error occurred handling a previous frame.
|
||||||
|
// Don't handle the current frame.
|
||||||
|
if handleErr != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
if err := s.handleFrame(frame, encLevel, destConnID); err != nil {
|
if err := s.handleFrame(frame, encLevel, destConnID); err != nil {
|
||||||
|
if log == nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
} else {
|
// If we're logging, we need to keep parsing (but not handling) all frames.
|
||||||
frames = append(frames, frame)
|
handleErr = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if log != nil {
|
if log != nil {
|
||||||
fs := make([]logging.Frame, len(frames))
|
log(frames)
|
||||||
for i, frame := range frames {
|
if handleErr != nil {
|
||||||
fs[i] = logutils.ConvertFrame(frame)
|
return false, handleErr
|
||||||
}
|
|
||||||
log(fs)
|
|
||||||
for _, frame := range frames {
|
|
||||||
if err := s.handleFrame(frame, encLevel, destConnID); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user