From 2a22e73880edeea9a67e0a8e234f056a17b60549 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Wed, 3 Dec 2003 14:47:28 +0000 Subject: [PATCH] use a list of getter maps --- helm/http_getter/http_getter.ml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/helm/http_getter/http_getter.ml b/helm/http_getter/http_getter.ml index 366c233b4..ec6564249 100644 --- a/helm/http_getter/http_getter.ml +++ b/helm/http_getter/http_getter.ml @@ -95,8 +95,11 @@ let nuprl_map = new Http_getter_map.map Http_getter_env.nuprl_dbm in 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 @@ -350,7 +353,7 @@ let update_from_server logmsg server_url = (* use global maps *) !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 @@ -358,7 +361,7 @@ let update_from_all_servers () = (* use global maps *) (* 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 @@ -523,12 +526,12 @@ let main () = 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 () -- 2.39.2