let rdf_map = new Http_getter_map.map Http_getter_env.rdf_dbm in
let xsl_map = new Http_getter_map.map Http_getter_env.xsl_dbm in
-let save_maps () =
- cic_map#close; nuprl_map#close; rdf_map#close; xsl_map#close in
+let maps = [ cic_map; nuprl_map; rdf_map; xsl_map ] in
+let close_maps () = List.iter (fun m -> m#close) maps in
+let clear_maps () = List.iter (fun m -> m#clear) maps in
+let sync_maps () = List.iter (fun m -> m#sync) maps in
+
let map_of_uri = function
| uri when is_cic_uri uri -> cic_map
| uri when is_nuprl_uri uri -> nuprl_map
!log
in
let update_from_all_servers () = (* use global maps *)
- cic_map#clear; nuprl_map#clear; rdf_map#clear; xsl_map#clear;
+ clear_maps ();
let log =
List.fold_left
update_from_server
(* reverse order: 1st server is the most important one *)
(List.rev !Http_getter_env.servers)
in
- cic_map#sync; nuprl_map#sync; rdf_map#sync; xsl_map#sync;
+ sync_maps ();
log
in
print_string (Http_getter_env.env_to_string ());
flush stdout;
Unix.putenv "http_proxy" "";
- at_exit save_maps;
+ at_exit close_maps;
Sys.catch_break true;
try
Http_daemon.start'
~timeout:(Some 600) ~port:Http_getter_env.port ~mode:`Thread callback
- with Sys.Break -> () (* 'save_maps' already registered with 'at_exit' *)
+ with Sys.Break -> () (* 'close_maps' already registered with 'at_exit' *)
in
main ()