diff --git a/src/bin/krill.rs b/src/bin/krill.rs index 346d2c8f..81a20489 100644 --- a/src/bin/krill.rs +++ b/src/bin/krill.rs @@ -1,11 +1,3 @@ -// Added so that the call chain from http/auth.rs through to Authorizer doesn't -// exceed the recursion limit within future macro expansion. Possibly related to -// this: -// "Note that select! relies on proc-macro-hack, and may require to set the -// compiler's recursion limit very high, e.g. #![recursion_limit="1024"]." -// From: https://docs.rs/futures/0.3.6/futures/macro.select.html -#![recursion_limit = "155"] - extern crate krill; use std::env; diff --git a/src/bin/krillc.rs b/src/bin/krillc.rs index b5708484..e23dc49f 100644 --- a/src/bin/krillc.rs +++ b/src/bin/krillc.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - extern crate krill; use krill::cli::options::Options; diff --git a/src/bin/krillpubc.rs b/src/bin/krillpubc.rs index dbea5008..1098a5b8 100644 --- a/src/bin/krillpubc.rs +++ b/src/bin/krillpubc.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - extern crate krill; use krill::cli::options::KrillPubcOptions; diff --git a/src/bin/krillpubd.rs b/src/bin/krillpubd.rs index a7bfc42c..4ad60b3e 100644 --- a/src/bin/krillpubd.rs +++ b/src/bin/krillpubd.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - extern crate krill; use std::sync::Arc; diff --git a/src/daemon/http/server.rs b/src/daemon/http/server.rs index 716f1a22..b1e105e3 100644 --- a/src/daemon/http/server.rs +++ b/src/daemon/http/server.rs @@ -201,20 +201,29 @@ async fn map_requests(req: hyper::Request, state: State) -> Result< // just make the trace log unusable. let logger = ApiCallLogger::new(&req); - let res = api(req) - .or_else(auth) - .or_else(health) - .or_else(metrics) - .or_else(stats) - .or_else(rfc8181) - .or_else(rfc6492) - .or_else(statics) - .or_else(ta) - .or_else(rrdp) - .or_else(testbed) - .or_else(render_not_found) - .map_err(|_| Error::custom("should have received not found response")) - .await; + // We used to use .or_else() here but that causes a large recursive call + // tree due to these calls being to async functions, large enough with the + // given Request object passed each time that it eventually resulted in + // stack overflow. By doing it by hand like this we avoid the use of the + // macros that cause the recursion. We could also look at putting less data + // on the stack. + let mut res = api(req).await; + if let Err(req) = res { res = auth(req).await; } + if let Err(req) = res { res = health(req).await; } + if let Err(req) = res { res = metrics(req).await; } + if let Err(req) = res { res = stats(req).await; } + if let Err(req) = res { res = rfc8181(req).await; } + if let Err(req) = res { res = rfc6492(req).await; } + if let Err(req) = res { res = statics(req).await; } + if let Err(req) = res { res = ta(req).await; } + if let Err(req) = res { res = rrdp(req).await; } + if let Err(req) = res { res = testbed(req).await; } + if let Err(req) = res { res = render_not_found(req).await; } + + let res = match res { + Ok(res) => Ok(res), + Err(_) => Err(Error::custom("should have received not found response")), + }; // Augment the response with any updated auth details that were determined // above. diff --git a/src/lib.rs b/src/lib.rs index 6bcd445b..651ae93d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - extern crate base64; #[macro_use] extern crate bcder; diff --git a/tests/functional.rs b/tests/functional.rs index ceaf2f82..9b43c753 100644 --- a/tests/functional.rs +++ b/tests/functional.rs @@ -1,7 +1,5 @@ //! Perform functional tests on a Krill instance, using the API //! -#![recursion_limit = "155"] - use std::fs; use std::str::FromStr; use std::time::Duration; diff --git a/tests/history.rs b/tests/history.rs index 8b1c7f0c..bd58442b 100644 --- a/tests/history.rs +++ b/tests/history.rs @@ -1,6 +1,3 @@ -#![type_length_limit = "5000000"] -#![recursion_limit = "155"] - extern crate krill; /// This tests regressions for the Command history and details as exposed through the diff --git a/tests/multi_user_config_file.rs b/tests/multi_user_config_file.rs index adb7592e..b16440a2 100644 --- a/tests/multi_user_config_file.rs +++ b/tests/multi_user_config_file.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - #[cfg(feature = "ui-tests")] mod ui; diff --git a/tests/multi_user_config_file_with_ta.rs b/tests/multi_user_config_file_with_ta.rs index e3a2897c..b6de8c41 100644 --- a/tests/multi_user_config_file_with_ta.rs +++ b/tests/multi_user_config_file_with_ta.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - #[cfg(feature = "ui-tests")] mod ui; diff --git a/tests/multi_user_master_token.rs b/tests/multi_user_master_token.rs index 260b7f8a..6a4b638f 100644 --- a/tests/multi_user_master_token.rs +++ b/tests/multi_user_master_token.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - #[cfg(feature = "ui-tests")] mod ui; diff --git a/tests/multi_user_openid_connect.rs b/tests/multi_user_openid_connect.rs index b288baad..0bc9e4eb 100644 --- a/tests/multi_user_openid_connect.rs +++ b/tests/multi_user_openid_connect.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - #[cfg(feature = "ui-tests")] mod ui; diff --git a/tests/multi_user_team_policy.rs b/tests/multi_user_team_policy.rs index 3080af14..c7fc9d37 100644 --- a/tests/multi_user_team_policy.rs +++ b/tests/multi_user_team_policy.rs @@ -1,5 +1,3 @@ -#![recursion_limit = "155"] - #[cfg(feature = "ui-tests")] mod ui; diff --git a/tests/testbed.rs b/tests/testbed.rs index 3c2c23b3..217f0ad8 100644 --- a/tests/testbed.rs +++ b/tests/testbed.rs @@ -1,5 +1,4 @@ #![type_length_limit = "5000000"] -#![recursion_limit = "155"] extern crate krill;