Skip to content

Commit db231fc

Browse files
committed
Merge pull request xapi-project#1763 from akshayramani/SCTX-1665.f
Add a configurable idle timeout to stunnel
2 parents 2ac377e + 53ef46d commit db231fc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

ocaml/xapi/xapi.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,14 @@ let listen_unix_socket () =
680680
let domain_sock = Xapi_http.bind (Unix.ADDR_UNIX(Xapi_globs.unix_domain_socket)) in
681681
ignore(Http_svr.start Xapi_http.server domain_sock)
682682

683+
let set_stunnel_timeout () =
684+
try
685+
let timeout = int_of_string (Xapi_inventory.lookup Xapi_inventory._stunnel_idle_timeout) in
686+
debug "Setting stunnel timeout to %d" timeout;
687+
Stunnel.timeoutidle := Some timeout
688+
with _ ->
689+
debug "Using default stunnel timeout (usually 43200)"
690+
683691
let server_init() =
684692
let print_server_starting_message() = debug "on_system_boot=%b pool_role=%s" !Xapi_globs.on_system_boot (Pool_role.string_of (Pool_role.get_role ())) in
685693

@@ -783,6 +791,7 @@ let server_init() =
783791
Startup.run ~__context [
784792
"XAPI SERVER STARTING", [], print_server_starting_message;
785793
"Parsing inventory file", [], Xapi_inventory.read_inventory;
794+
"Setting stunnel timeout", [], set_stunnel_timeout;
786795
"Initialising local database", [], init_local_database;
787796
"Loading DHCP leases", [], Xapi_udhcpd.init;
788797
"Reading pool secret", [], Helpers.get_pool_secret;

scripts/init.d-xapissl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ mgmt_ip() {
5252
writeconffile () {
5353
# Initial boilerplate which is valid whether the management
5454
# interface is enabled or disabled.
55-
cat > $SSLCONFFILE <<EOF
55+
. /etc/xensource-inventory
56+
57+
if [ -n "${STUNNEL_IDLE_TIMEOUT}" ]; then
58+
TIMEOUTSTR="TIMEOUTidle = ${STUNNEL_IDLE_TIMEOUT}"
59+
fi
60+
cat > $SSLCONFFILE <<EOF
5661
; Autogenerated by init.d/xapissl
5762
pid = ${SSLPIDFILE}
5863
socket = r:TCP_NODELAY=1
@@ -61,6 +66,7 @@ socket = l:TCP_NODELAY=1
6166
socket = r:SO_KEEPALIVE=1
6267
socket = a:SO_KEEPALIVE=1
6368
compression = zlib
69+
${TIMEOUTSTR}
6470
6571
[xapi]
6672
accept = ${ACCEPT}

0 commit comments

Comments
 (0)