Skip to content

Commit 9aa9e7e

Browse files
committed
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 <[email protected]>
1 parent bb672a9 commit 9aa9e7e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

ocaml/xapi/xapi_globs.ml

+8
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,9 @@ let disable_webserver = ref false
10781078
let reuse_pool_sessions = ref true
10791079
(* Enables the reuse of pool sessions, speeding up intrapool communication *)
10801080

1081+
let validate_reusable_pool_session = ref false
1082+
(* Validate a reusable session before each use. This is slower and should not be required *)
1083+
10811084
let test_open = ref 0
10821085

10831086
let tgroups_enabled = ref false
@@ -1717,6 +1720,11 @@ let other_options =
17171720
, (fun () -> string_of_bool !reuse_pool_sessions)
17181721
, "Enable the reuse of pool sessions"
17191722
)
1723+
; ( "validate-reusable-pool-session"
1724+
, Arg.Set validate_reusable_pool_session
1725+
, (fun () -> string_of_bool !validate_reusable_pool_session)
1726+
, "Enable validation of reusable pool sessions before use"
1727+
)
17201728
]
17211729

17221730
(* The options can be set with the variable xapiflags in /etc/sysconfig/xapi.

ocaml/xapi/xapi_session.ml

+7-3
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,12 @@ let login_no_password_common ~__context ~uname ~originator ~host ~pool
671671
~rbac_permissions ~db_ref ~client_certificate =
672672
Context.with_tracing ~originator ~__context __FUNCTION__ @@ fun __context ->
673673
let is_valid_session session_id =
674-
if session_id = Ref.null then
675-
false
676-
else
674+
match (session_id, !Xapi_globs.validate_reusable_pool_session) with
675+
| session, _ when session = Ref.null ->
676+
false
677+
| _, false ->
678+
true
679+
| session_id, true -> (
677680
try
678681
(* Call an API function to check the session is still valid *)
679682
let rpc = Helpers.make_rpc ~__context in
@@ -682,6 +685,7 @@ let login_no_password_common ~__context ~uname ~originator ~host ~pool
682685
with Api_errors.Server_error (err, _) ->
683686
debug "%s: Invalid session: %s" __FUNCTION__ err ;
684687
false
688+
)
685689
in
686690
let create_session () =
687691
login_no_password_common_create_session ~__context ~uname ~originator ~host

0 commit comments

Comments
 (0)