@@ -128,7 +128,7 @@ mod ebpf_enhanced {
128128 ) ;
129129
130130 if let Some ( result) = self . try_ebpf_lookup ( conn) {
131- let mut stats = self . stats . write ( ) . unwrap ( ) ;
131+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
132132 stats. ebpf_hits += 1 ;
133133 debug ! (
134134 "Enhanced lookup: eBPF hit for PID {} ({})" ,
@@ -153,7 +153,7 @@ mod ebpf_enhanced {
153153 ) ;
154154
155155 if let Some ( result) = self . try_ebpf_icmp_lookup ( conn, * id) {
156- let mut stats = self . stats . write ( ) . unwrap ( ) ;
156+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
157157 stats. ebpf_hits += 1 ;
158158 debug ! (
159159 "Enhanced lookup: eBPF ICMP hit for PID {} ({})" ,
@@ -170,7 +170,7 @@ mod ebpf_enhanced {
170170
171171 // Fall back to procfs approach
172172 if let Some ( result) = self . procfs_lookup . get_process_for_connection ( conn) {
173- let mut stats = self . stats . write ( ) . unwrap ( ) ;
173+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
174174 stats. procfs_hits += 1 ;
175175 return Some ( result) ;
176176 }
@@ -179,7 +179,10 @@ mod ebpf_enhanced {
179179 }
180180
181181 fn try_ebpf_lookup ( & self , conn : & Connection ) -> Option < ( u32 , String ) > {
182- let mut tracker_guard = self . ebpf_tracker . write ( ) . unwrap ( ) ;
182+ let mut tracker_guard = self
183+ . ebpf_tracker
184+ . write ( )
185+ . expect ( "ebpf_tracker lock poisoned" ) ;
183186 let tracker = match tracker_guard. as_mut ( ) {
184187 Some ( t) => {
185188 debug ! ( "eBPF lookup: Tracker available, performing lookup" ) ;
@@ -240,7 +243,10 @@ mod ebpf_enhanced {
240243 }
241244
242245 fn try_ebpf_icmp_lookup ( & self , conn : & Connection , icmp_id : u16 ) -> Option < ( u32 , String ) > {
243- let mut tracker_guard = self . ebpf_tracker . write ( ) . unwrap ( ) ;
246+ let mut tracker_guard = self
247+ . ebpf_tracker
248+ . write ( )
249+ . expect ( "ebpf_tracker lock poisoned" ) ;
244250 let tracker = tracker_guard. as_mut ( ) ?;
245251
246252 match tracker. lookup_icmp ( conn. local_addr . ip ( ) , conn. remote_addr . ip ( ) , icmp_id) {
@@ -276,7 +282,7 @@ mod ebpf_enhanced {
276282 pub fn is_ebpf_available ( & self ) -> bool {
277283 self . ebpf_tracker
278284 . read ( )
279- . unwrap ( )
285+ . expect ( "ebpf_tracker lock poisoned" )
280286 . as_ref ( )
281287 . map ( |t| t. is_healthy ( ) )
282288 . unwrap_or ( false )
@@ -285,7 +291,10 @@ mod ebpf_enhanced {
285291 /// Perform periodic cleanup of stale eBPF map entries
286292 fn maybe_cleanup_ebpf_map ( & self ) {
287293 let now = Instant :: now ( ) ;
288- let mut last_cleanup = self . last_cleanup . write ( ) . unwrap ( ) ;
294+ let mut last_cleanup = self
295+ . last_cleanup
296+ . write ( )
297+ . expect ( "last_cleanup lock poisoned" ) ;
289298
290299 if now. duration_since ( * last_cleanup) . as_secs ( )
291300 >= self . cleanup_config . cleanup_interval_secs
@@ -294,7 +303,12 @@ mod ebpf_enhanced {
294303 drop ( last_cleanup) ;
295304
296305 // Perform cleanup
297- if let Some ( tracker) = self . ebpf_tracker . write ( ) . unwrap ( ) . as_mut ( ) {
306+ if let Some ( tracker) = self
307+ . ebpf_tracker
308+ . write ( )
309+ . expect ( "ebpf_tracker lock poisoned" )
310+ . as_mut ( )
311+ {
298312 let cleaned =
299313 tracker. cleanup_stale_entries ( self . cleanup_config . stale_threshold_secs ) ;
300314 if cleaned > 0 {
@@ -314,7 +328,7 @@ mod ebpf_enhanced {
314328
315329 // Update protocol statistics
316330 {
317- let mut stats = self . stats . write ( ) . unwrap ( ) ;
331+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
318332 stats. total_lookups += 1 ;
319333
320334 // Track IP version
@@ -336,11 +350,14 @@ mod ebpf_enhanced {
336350
337351 // Try cache first
338352 {
339- let cache = self . unified_cache . read ( ) . unwrap ( ) ;
353+ let cache = self
354+ . unified_cache
355+ . read ( )
356+ . expect ( "unified_cache lock poisoned" ) ;
340357 if cache. last_refresh . elapsed ( ) < Duration :: from_secs ( 2 )
341358 && let Some ( process_info) = cache. lookup . get ( & key)
342359 {
343- let mut stats = self . stats . write ( ) . unwrap ( ) ;
360+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
344361 stats. cache_hits += 1 ;
345362 return Some ( process_info. clone ( ) ) ;
346363 }
@@ -350,16 +367,19 @@ mod ebpf_enhanced {
350367 if let Some ( result) = self . lookup_process_enhanced ( conn) {
351368 // Update cache with the result
352369 {
353- let mut cache = self . unified_cache . write ( ) . unwrap ( ) ;
370+ let mut cache = self
371+ . unified_cache
372+ . write ( )
373+ . expect ( "unified_cache lock poisoned" ) ;
354374 cache. lookup . insert ( key, result. clone ( ) ) ;
355375
356- let mut stats = self . stats . write ( ) . unwrap ( ) ;
376+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
357377 stats. cache_entries = cache. lookup . len ( ) as u64 ;
358378 }
359379 Some ( result)
360380 } else {
361381 // Track failed lookups
362- let mut stats = self . stats . write ( ) . unwrap ( ) ;
382+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
363383 stats. failed_lookups += 1 ;
364384 None
365385 }
@@ -371,7 +391,10 @@ mod ebpf_enhanced {
371391
372392 // Update our cache timestamp
373393 {
374- let mut cache = self . unified_cache . write ( ) . unwrap ( ) ;
394+ let mut cache = self
395+ . unified_cache
396+ . write ( )
397+ . expect ( "unified_cache lock poisoned" ) ;
375398 cache. last_refresh = Instant :: now ( ) ;
376399 // Optionally clear cache to force fresh lookups
377400 cache. lookup . clear ( ) ;
@@ -538,7 +561,7 @@ mod procfs_only {
538561
539562 // Update protocol statistics
540563 {
541- let mut stats = self . stats . write ( ) . unwrap ( ) ;
564+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
542565 stats. total_lookups += 1 ;
543566
544567 // Track IP version
@@ -560,11 +583,14 @@ mod procfs_only {
560583
561584 // Try cache first
562585 {
563- let cache = self . unified_cache . read ( ) . unwrap ( ) ;
586+ let cache = self
587+ . unified_cache
588+ . read ( )
589+ . expect ( "unified_cache lock poisoned" ) ;
564590 if cache. last_refresh . elapsed ( ) < Duration :: from_secs ( 2 )
565591 && let Some ( process_info) = cache. lookup . get ( & key)
566592 {
567- let mut stats = self . stats . write ( ) . unwrap ( ) ;
593+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
568594 stats. cache_hits += 1 ;
569595 return Some ( process_info. clone ( ) ) ;
570596 }
@@ -574,17 +600,20 @@ mod procfs_only {
574600 if let Some ( result) = self . procfs_lookup . get_process_for_connection ( conn) {
575601 // Update cache with the result
576602 {
577- let mut cache = self . unified_cache . write ( ) . unwrap ( ) ;
603+ let mut cache = self
604+ . unified_cache
605+ . write ( )
606+ . expect ( "unified_cache lock poisoned" ) ;
578607 cache. lookup . insert ( key, result. clone ( ) ) ;
579608
580- let mut stats = self . stats . write ( ) . unwrap ( ) ;
609+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
581610 stats. cache_entries = cache. lookup . len ( ) as u64 ;
582611 stats. procfs_hits += 1 ;
583612 }
584613 Some ( result)
585614 } else {
586615 // Track failed lookups
587- let mut stats = self . stats . write ( ) . unwrap ( ) ;
616+ let mut stats = self . stats . write ( ) . expect ( "stats lock poisoned" ) ;
588617 stats. failed_lookups += 1 ;
589618 None
590619 }
@@ -596,7 +625,10 @@ mod procfs_only {
596625
597626 // Update our cache timestamp
598627 {
599- let mut cache = self . unified_cache . write ( ) . unwrap ( ) ;
628+ let mut cache = self
629+ . unified_cache
630+ . write ( )
631+ . expect ( "unified_cache lock poisoned" ) ;
600632 cache. last_refresh = Instant :: now ( ) ;
601633 // Optionally clear cache to force fresh lookups
602634 cache. lookup . clear ( ) ;
0 commit comments