From abfec5d6795bbeb403259fc9389c9d5158358418 Mon Sep 17 00:00:00 2001 From: erikness-doordash Date: Mon, 21 Aug 2023 17:15:01 -0700 Subject: [PATCH 1/7] Change panic to trace log Signed-off-by: erikness-doordash --- src/dispatcher.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index b562201c..37d2242a 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -428,11 +428,17 @@ impl Dispatcher { } fn on_grpc_receive_initial_metadata(&self, token_id: u32, headers: u32) { - let context_id = *self - .grpc_streams - .borrow_mut() - .get(&token_id) - .expect("invalid token_id"); + let grpc_streams_ref = self.grpc_streams.borrow_mut(); + let context_id_hash_slot = grpc_streams_ref + .get(&token_id); + let context_id = match context_id_hash_slot { + Some(id) => *id, + None => { + // TODO: change back to a panic once underlying issue is fixed. + trace!("on_grpc_receive_initial_metadata: invalid token_id"); + return; + } + }; if let Some(http_stream) = self.http_streams.borrow_mut().get_mut(&context_id) { self.active_id.set(context_id); From aeaa5db8168aee17485a41026fe289359d314fb0 Mon Sep 17 00:00:00 2001 From: erikness-doordash Date: Wed, 18 Oct 2023 16:53:34 -0700 Subject: [PATCH 2/7] Apply the same fix to on_grpc_receiving_trailing_metadata() too Signed-off-by: erikness-doordash --- src/dispatcher.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index 37d2242a..a36ca3b9 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -491,11 +491,17 @@ impl Dispatcher { } fn on_grpc_receive_trailing_metadata(&self, token_id: u32, trailers: u32) { - let context_id = *self - .grpc_streams - .borrow_mut() - .get(&token_id) - .expect("invalid token_id"); + let grpc_streams_ref = self.grpc_streams.borrow_mut(); + let context_id_hash_slot = grpc_streams_ref + .get(&token_id); + let context_id = match context_id_hash_slot { + Some(id) => *id, + None => { + // TODO: change back to a panic once underlying issue is fixed. + trace!("on_grpc_receive_initial_metadata: invalid token_id"); + return; + } + }; if let Some(http_stream) = self.http_streams.borrow_mut().get_mut(&context_id) { self.active_id.set(context_id); From 2e6867b027967c64c03c75c6e2ee8e7c9ba69f0f Mon Sep 17 00:00:00 2001 From: erikness-doordash Date: Thu, 19 Oct 2023 09:42:07 -0700 Subject: [PATCH 3/7] Make cargo fmt happy Signed-off-by: erikness-doordash --- src/dispatcher.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index a36ca3b9..8ee1d1fd 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -429,8 +429,7 @@ impl Dispatcher { fn on_grpc_receive_initial_metadata(&self, token_id: u32, headers: u32) { let grpc_streams_ref = self.grpc_streams.borrow_mut(); - let context_id_hash_slot = grpc_streams_ref - .get(&token_id); + let context_id_hash_slot = grpc_streams_ref.get(&token_id); let context_id = match context_id_hash_slot { Some(id) => *id, None => { @@ -492,8 +491,7 @@ impl Dispatcher { fn on_grpc_receive_trailing_metadata(&self, token_id: u32, trailers: u32) { let grpc_streams_ref = self.grpc_streams.borrow_mut(); - let context_id_hash_slot = grpc_streams_ref - .get(&token_id); + let context_id_hash_slot = grpc_streams_ref.get(&token_id); let context_id = match context_id_hash_slot { Some(id) => *id, None => { From bbc50f283ea5122c3be36fca96d76092f03bbc14 Mon Sep 17 00:00:00 2001 From: erikness-doordash Date: Thu, 19 Oct 2023 16:29:22 -0700 Subject: [PATCH 4/7] Typo (wrong method) in trailing metadata log Signed-off-by: erikness-doordash --- src/dispatcher.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index 8ee1d1fd..b48ff88a 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -496,7 +496,7 @@ impl Dispatcher { Some(id) => *id, None => { // TODO: change back to a panic once underlying issue is fixed. - trace!("on_grpc_receive_initial_metadata: invalid token_id"); + trace!("on_grpc_receive_trailing_metadata: invalid token_id"); return; } }; From c4684fbb55ced61533753269ea2051124440c86c Mon Sep 17 00:00:00 2001 From: erikness-doordash Date: Mon, 23 Oct 2023 15:35:14 -0700 Subject: [PATCH 5/7] Simplify code into 1 statement Signed-off-by: erikness-doordash --- src/dispatcher.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index b48ff88a..a1bbc7eb 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -428,9 +428,7 @@ impl Dispatcher { } fn on_grpc_receive_initial_metadata(&self, token_id: u32, headers: u32) { - let grpc_streams_ref = self.grpc_streams.borrow_mut(); - let context_id_hash_slot = grpc_streams_ref.get(&token_id); - let context_id = match context_id_hash_slot { + let context_id = match self.grpc_streams.borrow_mut().get(&token_id) { Some(id) => *id, None => { // TODO: change back to a panic once underlying issue is fixed. @@ -490,9 +488,7 @@ impl Dispatcher { } fn on_grpc_receive_trailing_metadata(&self, token_id: u32, trailers: u32) { - let grpc_streams_ref = self.grpc_streams.borrow_mut(); - let context_id_hash_slot = grpc_streams_ref.get(&token_id); - let context_id = match context_id_hash_slot { + let context_id = match self.grpc_streams.borrow_mut().get(&token_id) { Some(id) => *id, None => { // TODO: change back to a panic once underlying issue is fixed. From 56e15b4dce65a06bdb10dd60c04d26bd912ef140 Mon Sep 17 00:00:00 2001 From: erikness-doordash Date: Wed, 25 Oct 2023 12:53:44 -0700 Subject: [PATCH 6/7] Panic to trace for on_grpc_receive() as well Signed-off-by: erikness-doordash --- src/dispatcher.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index a1bbc7eb..7acb14a6 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -483,7 +483,9 @@ impl Dispatcher { root.on_grpc_stream_message(token_id, response_size); } } else { - panic!("invalid token_id") + // TODO: change back to a panic once underlying issue is fixed. + trace!("on_grpc_receive_initial_metadata: invalid token_id"); + return; } } From 893b1d32b4a8f9856d04b1154c7c1a8a34287c76 Mon Sep 17 00:00:00 2001 From: erikness-doordash Date: Tue, 7 Nov 2023 14:16:21 -0800 Subject: [PATCH 7/7] Remove redundant return statement Signed-off-by: erikness-doordash --- src/dispatcher.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dispatcher.rs b/src/dispatcher.rs index 7acb14a6..4d1f16fa 100644 --- a/src/dispatcher.rs +++ b/src/dispatcher.rs @@ -485,7 +485,6 @@ impl Dispatcher { } else { // TODO: change back to a panic once underlying issue is fixed. trace!("on_grpc_receive_initial_metadata: invalid token_id"); - return; } }