From c27b1d45b9a209ae922250a54b2a0a076af7a531 Mon Sep 17 00:00:00 2001 From: Steven Woods Date: Mon, 23 Sep 2024 11:30:08 +0100 Subject: [PATCH] CP-48676: Don't check resuable pool session validity by default Add a new flag validate-reusable-pool-session to xapi globs which skips the reusable pool session validity check if it is false. This saves time as we are no longer calling pool.get_all for each session. Signed-off-by: Steven Woods --- ocaml/xapi/xapi_globs.ml | 7 +++++++ ocaml/xapi/xapi_session.ml | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ocaml/xapi/xapi_globs.ml b/ocaml/xapi/xapi_globs.ml index 3fbe0d36b4f..1b0d7c9bdd5 100644 --- a/ocaml/xapi/xapi_globs.ml +++ b/ocaml/xapi/xapi_globs.ml @@ -1055,6 +1055,8 @@ let disable_webserver = ref false let reuse_pool_sessions = ref true +let validate_reusable_pool_session = ref false + let test_open = ref 0 let xapi_globs_spec = @@ -1625,6 +1627,11 @@ let other_options = , (fun () -> string_of_bool !reuse_pool_sessions) , "Enable the reuse of pool sessions" ) + ; ( "validate-reusable-pool-session" + , Arg.Set validate_reusable_pool_session + , (fun () -> string_of_bool !validate_reusable_pool_session) + , "Enable the reuse of pool sessions" + ) ] (* The options can be set with the variable xapiflags in /etc/sysconfig/xapi. diff --git a/ocaml/xapi/xapi_session.ml b/ocaml/xapi/xapi_session.ml index abced81ca42..bd981cb3692 100644 --- a/ocaml/xapi/xapi_session.ml +++ b/ocaml/xapi/xapi_session.ml @@ -701,7 +701,9 @@ let login_no_password_common ~__context ~uname ~originator ~host ~pool with_lock reusable_pool_session_lock (fun () -> if !reusable_pool_session <> Ref.null - && is_valid_session !reusable_pool_session + && ((not !Xapi_globs.validate_reusable_pool_session) + || is_valid_session !reusable_pool_session + ) then !reusable_pool_session else