From 67b126ded904b0388bb32039d3217fa37099d33f Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Tue, 7 Jan 2003 18:22:59 +0000 Subject: [PATCH] - added support for 'reload' method which is supposed to be invoked on SIGHUP, actually it only reloads servers list from servers.txt - changed servers type from string list to string list ref to permit changes on reload --- helm/http_getter/http_getter_env.ml | 13 +++++++++---- helm/http_getter/http_getter_env.mli | 11 ++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/helm/http_getter/http_getter_env.ml b/helm/http_getter/http_getter_env.ml index 70696c596..e97c89cbf 100644 --- a/helm/http_getter/http_getter_env.ml +++ b/helm/http_getter/http_getter_env.ml @@ -73,9 +73,11 @@ let safe_getenv ?(from = Both) var = | v -> return_value var v))) let servers_file = safe_getenv "HTTP_GETTER_SERVERS_FILE" -let servers = - let cons hd tl = hd @ [ tl ] in - Http_getter_misc.fold_file cons [] servers_file +let parse_servers () = + (let cons hd tl = hd @ [ tl ] in + Http_getter_misc.fold_file cons [] servers_file) +let servers = ref (parse_servers ()) +let reload_servers () = servers := parse_servers () let xml_dbm = safe_getenv "HTTP_GETTER_XML_DBM" let rdf_dbm = safe_getenv "HTTP_GETTER_RDF_DBM" @@ -110,6 +112,9 @@ let cache_mode = | "gz" -> Enc_gzipped | mode -> failwith ("Invalid cache mode: " ^ mode) +let reload () = + reload_servers () + let dump_env () = printf "xml_dbm:\t%s @@ -136,6 +141,6 @@ servers: xml_dir rdf_dir dtd_dir servers_file host port my_own_url dtd_base_url (match cache_mode with Enc_normal -> "Normal" | Enc_gzipped -> "GZipped") - conf_file conf_dir (String.concat "\n\t" servers); + conf_file conf_dir (String.concat "\n\t" !servers); flush stdout diff --git a/helm/http_getter/http_getter_env.mli b/helm/http_getter/http_getter_env.mli index 7ce96f702..95378a3c7 100644 --- a/helm/http_getter/http_getter_env.mli +++ b/helm/http_getter/http_getter_env.mli @@ -43,15 +43,16 @@ (* derived data *) - val host : string (* host on which getter listens *) - val my_own_url : string (* URL at which contact getter *) - val servers : string list (* servers list (i.e. servers_file lines) *) + val host : string (* host on which getter listens *) + val my_own_url : string (* URL at which contact getter *) + val servers : string list ref (* servers list *) val cache_mode : http_getter_encoding (* cached files encoding *) - val conf_file : string (* configuration file's full path *) - val conf_dir : string (* directory where conf_file resides *) + val conf_file : string (* configuration file's full path *) + val conf_dir : string (* directory where conf_file resides *) (* misc *) +val reload: unit -> unit (* reload servers list *) val dump_env : unit -> unit (* dump a textual representation of the current http_getter settings *) -- 2.39.2