From faafe87ce2f7906abc4638cd8f69d1b82dece371 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Mon, 23 Feb 2004 18:36:54 +0000 Subject: [PATCH] A lazy value was put in place of a function ==> the memoized value was no longer updated. Fixed. --- helm/ocaml/getter/http_getter.ml | 6 +++--- helm/ocaml/getter/http_getter_env.ml | 10 +++++----- helm/ocaml/getter/http_getter_env.mli | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/helm/ocaml/getter/http_getter.ml b/helm/ocaml/getter/http_getter.ml index 38683430d..21ed483ad 100644 --- a/helm/ocaml/getter/http_getter.ml +++ b/helm/ocaml/getter/http_getter.ml @@ -164,7 +164,7 @@ let update_from_all_servers () = (* use global maps *) update_from_server [] (* initial logmsg: empty *) (* reverse order: 1st server is the most important one *) - (List.map snd (List.rev (Lazy.force Http_getter_env.servers))) + (List.map snd (List.rev (Http_getter_env.servers ()))) in sync_maps (); `Msg (`L (List.rev log)) @@ -309,7 +309,7 @@ let list_servers () = if remote () then list_servers_remote () else - Lazy.force Http_getter_env.servers + Http_getter_env.servers () let add_server ?(position = 0) name = if remote () then @@ -331,7 +331,7 @@ let remove_server position = else begin let server_name = try - List.assoc position (Lazy.force Http_getter_env.servers) + List.assoc position (Http_getter_env.servers ()) with Not_found -> raise (Invalid_argument (sprintf "no server with position %d" position)) in diff --git a/helm/ocaml/getter/http_getter_env.ml b/helm/ocaml/getter/http_getter_env.ml index 623be8aef..3264d6c65 100644 --- a/helm/ocaml/getter/http_getter_env.ml +++ b/helm/ocaml/getter/http_getter_env.ml @@ -53,7 +53,7 @@ let port = lazy (Helm_registry.get_int "getter.port") let _servers = ref None let servers = - lazy + function () -> (match !_servers with | None -> failwith "Getter not yet initialized: servers not available" | Some servers -> servers) @@ -74,7 +74,7 @@ let reload_servers () = _servers := Some (load_servers ()) let save_servers () = let oc = open_out (Lazy.force servers_file) in List.iter (fun (_,server) -> output_string oc (server ^ "\n")) - (Lazy.force servers); + (servers ()); close_out oc let host = @@ -132,11 +132,11 @@ servers: (match Lazy.force cache_mode with Enc_normal -> "Normal" | Enc_gzipped -> "GZipped") (String.concat "\n\t" (* (position * server) list *) (List.map (fun (pos, server) -> sprintf "%3d: %s" pos server) - (Lazy.force servers))) + (servers ()))) let add_server ?position url = let new_servers = - let servers = Lazy.force servers in + let servers = servers () in match position with | None -> servers @ [-1, url]; | Some p when p > 0 -> @@ -154,7 +154,7 @@ let add_server ?position url = reload_servers () let remove_server position = - _servers := Some (List.remove_assoc position (Lazy.force servers)); + _servers := Some (List.remove_assoc position (servers ())); save_servers (); reload_servers () diff --git a/helm/ocaml/getter/http_getter_env.mli b/helm/ocaml/getter/http_getter_env.mli index cb1731792..f55867c92 100644 --- a/helm/ocaml/getter/http_getter_env.mli +++ b/helm/ocaml/getter/http_getter_env.mli @@ -53,7 +53,7 @@ val dtd_base_url : string lazy_t (* base URL for DTD downloading *) val host : string lazy_t (* host on which getter listens *) val my_own_url : string lazy_t (* URL at which contact getter *) -val servers : (int * string) list lazy_t +val servers : unit -> (int * string) list (* (position * server) list *) val cache_mode : encoding lazy_t (* cached files encoding *) -- 2.39.2