<commit_before>(*
 * Copyright (C) 2006-2009 Citrix Systems Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; version 2.1 only. with the special
 * exception on linking described in file LICENSE.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *)
open Db_filter_types
open Pervasiveext
open Threadext

module D = Debug.Debugger(struct let name="xapi" end)
open D

(** Keep track of the management interface server thread *)

let himn_addr = ref None

(* Stores a key into the table in Http_srv which identifies the server thread bound
	 to the management IP. *)
let management_interface_server = ref []
let listening_all = ref false
let listening_localhost = ref false
let listening_himn = ref false
let management_m = Mutex.create ()

let update_mh_info_script = Filename.concat Fhs.libexecdir "update-mh-info"

let update_mh_info interface =
	let (_: string*string) = Forkhelpers.execute_command_get_output update_mh_info_script [ interface ] in
	()

let restart_stunnel accept =
	info "Restarting stunnel (accepting connections on %s)" accept;
	let (_ : Thread.t) = Thread.create (fun () ->
		Forkhelpers.execute_command_get_output (Filename.concat Fhs.libexecdir "xapissl") [ "restart"; accept ]) () in
	()

let stop () =
	debug "Shutting down the old management interface (if any)";
	List.iter (fun i -> Http_svr.stop i) !management_interface_server;	
	management_interface_server := [];
	listening_all := false;
	listening_localhost := false;
	listening_himn := false
<commit_msg>Ensure (by mutex) that only one "stunnel restart" runs at a time<commit_after>(*
 * Copyright (C) 2006-2009 Citrix Systems Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; version 2.1 only. with the special
 * exception on linking described in file LICENSE.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *)
open Db_filter_types
open Pervasiveext
open Threadext

module D = Debug.Debugger(struct let name="xapi" end)
open D

(** Keep track of the management interface server thread *)

let himn_addr = ref None

(* Stores a key into the table in Http_srv which identifies the server thread bound
	 to the management IP. *)
let management_interface_server = ref []
let listening_all = ref false
let listening_localhost = ref false
let listening_himn = ref false
let management_m = Mutex.create ()

let update_mh_info_script = Filename.concat Fhs.libexecdir "update-mh-info"

let update_mh_info interface =
	let (_: string*string) = Forkhelpers.execute_command_get_output update_mh_info_script [ interface ] in
	()

let stunnel_m = Mutex.create ()

let restart_stunnel accept =
	info "Restarting stunnel (accepting connections on %s)" accept;
	let (_ : Thread.t) = Thread.create (fun () ->
		Mutex.execute management_m (fun () ->
			Forkhelpers.execute_command_get_output (Filename.concat Fhs.libexecdir "xapissl") [ "restart"; accept ]
		)
	) () in
	()

let stop () =
	debug "Shutting down the old management interface (if any)";
	List.iter (fun i -> Http_svr.stop i) !management_interface_server;	
	management_interface_server := [];
	listening_all := false;
	listening_localhost := false;
	listening_himn := false

{'fraction_non_alphanumeric': 0.07858081471747701, 'fraction_numerical': 0.005256241787122208, 'mean_word_length': 4.613569321533923, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5154544', 'n_tokens_mistral': 1130, 'n_tokens_neox': 1092, 'n_words': 437}