From b5715246c14e5381c0f1631953c0f1e44a35c2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Thu, 15 May 2025 13:23:12 +0800 Subject: [PATCH] Add err check --- app/dispatcher/default.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/dispatcher/default.go b/app/dispatcher/default.go index deffb3d1..51685cc8 100644 --- a/app/dispatcher/default.go +++ b/app/dispatcher/default.go @@ -373,7 +373,10 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw return nil, ctx.Err() default: cachingStartingTimeStamp := time.Now() - cacheErr := cReader.Cache(payload, cacheDeadline) + err := cReader.Cache(payload, cacheDeadline) + if err != nil { + return nil, err + } cachingTimeElapsed := time.Since(cachingStartingTimeStamp) cacheDeadline -= cachingTimeElapsed @@ -383,9 +386,7 @@ func sniffer(ctx context.Context, cReader *cachedReader, metadataOnly bool, netw case common.ErrNoClue: // No Clue: protocol not matches, and sniffer cannot determine whether there will be a match or not totalAttempt++ case protocol.ErrProtoNeedMoreData: // Protocol Need More Data: protocol matches, but need more data to complete sniffing - if cacheErr != nil { // Cache error (e.g. timeout) counts for failed attempt - totalAttempt++ - } + // in this case, do not add totalAttempt(allow to read until timeout) default: return result, err }