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))
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
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
let _servers = ref None
let servers =
- lazy
+ function () ->
(match !_servers with
| None -> failwith "Getter not yet initialized: servers not available"
| Some servers -> 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 =
(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 ->
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 ()
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 *)