@@ -195,8 +195,12 @@ where
195195
196196 // load endpoint from cache for *responses*
197197 // call this before calling `perf_stats` because the latter may remove cached entry
198- fn load_endpoint_from_cache < ' a > ( & mut self , param : & ' a ParseParam ) -> Option < String > {
199- let key = LogCacheKey :: new ( param, self . session_id ( ) ) ;
198+ fn load_endpoint_from_cache < ' a > (
199+ & mut self ,
200+ param : & ' a ParseParam ,
201+ is_reversed : bool ,
202+ ) -> Option < String > {
203+ let key = LogCacheKey :: new ( param, self . session_id ( ) , is_reversed) ;
200204 match param. l7_perf_cache . borrow_mut ( ) . rrt_cache . get ( & key) {
201205 Some ( cached) if cached. endpoint . is_some ( ) => {
202206 let log = LogCache {
@@ -258,9 +262,10 @@ where
258262 ( & mut perf_cache. rrt_cache , & mut perf_cache. timeout_cache )
259263 } ,
260264 ) ;
261- let key = LogCacheKey :: new ( param, self . session_id ( ) ) ;
265+ let key = LogCacheKey :: new ( param, self . session_id ( ) , self . is_reversed ( ) ) ;
262266 let prev_info = rtt_cache. get_mut ( & key) ;
263267 let timeout_counter = timeout_cache. get_or_insert_mut ( param. flow_id ) ;
268+ let index = if self . is_reversed ( ) { 1 } else { 0 } ;
264269
265270 let Some ( prev_info) = prev_info else {
266271 // If the first log is a request and on blacklist, we still need to put it in cache to handle the response,
@@ -269,7 +274,7 @@ where
269274 // If the first log is a response, it's perf stats will not be counted here.
270275 // We need to know whether its corresponding request is on blacklist before accounting.
271276 let ret = if cur_info. msg_type == LogMessageType :: Request && !cur_info. on_blacklist {
272- timeout_counter. in_cache += 1 ;
277+ timeout_counter. in_cache [ index ] += 1 ;
273278 Some ( L7PerfStats :: from ( & cur_info) )
274279 } else {
275280 None
@@ -287,7 +292,8 @@ where
287292 if prev_info. msg_type != cur_info. msg_type && !merge_info. merged {
288293 merge_info. merged = true ;
289294 if !( prev_info. on_blacklist || cur_info. on_blacklist ) {
290- timeout_counter. in_cache = timeout_counter. in_cache . saturating_sub ( 1 ) ;
295+ timeout_counter. in_cache [ index] =
296+ timeout_counter. in_cache [ index] . saturating_sub ( 1 ) ;
291297 }
292298 }
293299
@@ -297,7 +303,7 @@ where
297303 keep_prev = !( merge_info. req_end && merge_info. resp_end ) ;
298304 } else {
299305 if prev_info. msg_type == LogMessageType :: Request && !prev_info. on_blacklist {
300- timeout_counter. in_cache = timeout_counter. in_cache . saturating_sub ( 1 ) ;
306+ timeout_counter. in_cache [ index ] = timeout_counter. in_cache [ index ] . saturating_sub ( 1 ) ;
301307 }
302308 }
303309
@@ -311,7 +317,7 @@ where
311317 if rrt > param. rrt_timeout as u64 {
312318 match prev_info. multi_merge_info . as_ref ( ) {
313319 Some ( info) if info. merged => ( ) ,
314- _ => timeout_counter. timeout += 1 ,
320+ _ => timeout_counter. timeout [ index ] += 1 ,
315321 }
316322 } else {
317323 perf_stats. update_rrt ( rrt) ;
@@ -339,7 +345,7 @@ where
339345 warn ! ( "l7 log info disorder with long time rrt {}" , rrt) ;
340346 match prev_info. multi_merge_info . as_ref ( ) {
341347 Some ( info) if info. merged => ( ) ,
342- _ => timeout_counter. timeout += 1 ,
348+ _ => timeout_counter. timeout [ index ] += 1 ,
343349 }
344350 }
345351
@@ -365,10 +371,10 @@ where
365371
366372 if prev_info. time > cur_info. time {
367373 if !cur_info. on_blacklist && cur_info. msg_type == LogMessageType :: Request {
368- timeout_counter. timeout += 1 ;
374+ timeout_counter. timeout [ index ] += 1 ;
369375 }
370376 if !prev_info. on_blacklist && prev_info. msg_type == LogMessageType :: Request {
371- timeout_counter. in_cache += 1 ;
377+ timeout_counter. in_cache [ index ] += 1 ;
372378 }
373379 if !cur_info. on_blacklist {
374380 Some ( L7PerfStats :: from ( & cur_info) )
@@ -377,10 +383,10 @@ where
377383 }
378384 } else {
379385 if !prev_info. on_blacklist && prev_info. msg_type == LogMessageType :: Request {
380- timeout_counter. timeout += 1 ;
386+ timeout_counter. timeout [ index ] += 1 ;
381387 }
382388 if !cur_info. on_blacklist && cur_info. msg_type == LogMessageType :: Request {
383- timeout_counter. in_cache += 1 ;
389+ timeout_counter. in_cache [ index ] += 1 ;
384390 }
385391 let prev_info = rtt_cache. put ( key, cur_info) . unwrap ( ) ;
386392 if !prev_info. on_blacklist {
@@ -394,7 +400,7 @@ where
394400 && prev_info. msg_type != cur_info. msg_type
395401 && !prev_info. multi_merge_info . as_ref ( ) . unwrap ( ) . merged
396402 {
397- timeout_counter. timeout += 1 ;
403+ timeout_counter. timeout [ index ] += 1 ;
398404 }
399405 if !keep_prev {
400406 rtt_cache. pop ( & key) ;
0 commit comments