mldonkey-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...


From: mldonkey-commits
Subject: [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...
Date: Sat, 17 Mar 2007 18:03:02 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       07/03/17 18:03:01

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonBlocking.ml commonWeb.ml 
        src/daemon/driver: driverMain.ml 
        src/networks/donkey: donkeyInteractive.ml donkeyOvernet.ml 
        src/networks/fasttrack: fasttrackServers.ml 
        src/utils/net  : http_client.ml ip.ml ip.mli 

Log message:
        patch #5781

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1207&r2=1.1208
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonBlocking.ml?cvsroot=mldonkey&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonWeb.ml?cvsroot=mldonkey&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverMain.ml?cvsroot=mldonkey&r1=1.137&r2=1.138
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyInteractive.ml?cvsroot=mldonkey&r1=1.150&r2=1.151
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyOvernet.ml?cvsroot=mldonkey&r1=1.76&r2=1.77
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/fasttrack/fasttrackServers.ml?cvsroot=mldonkey&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/net/http_client.ml?cvsroot=mldonkey&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/net/ip.ml?cvsroot=mldonkey&r1=1.26&r2=1.27
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/net/ip.mli?cvsroot=mldonkey&r1=1.8&r2=1.9

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1207
retrieving revision 1.1208
diff -u -b -r1.1207 -r1.1208
--- distrib/ChangeLog   17 Mar 2007 15:24:44 -0000      1.1207
+++ distrib/ChangeLog   17 Mar 2007 18:03:01 -0000      1.1208
@@ -15,6 +15,8 @@
 =========
 
 2007/03/17
+5781: web_infos: Load local file if remote file can not be accessed
+      (thx to xergius)
 5802: Telnet: Support non-ascii input (Hung-Te Lin)
 
 2007/03/16

Index: src/daemon/common/commonBlocking.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonBlocking.ml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/daemon/common/commonBlocking.ml 3 Apr 2006 20:35:05 -0000       1.2
+++ src/daemon/common/commonBlocking.ml 17 Mar 2007 18:03:01 -0000      1.3
@@ -93,8 +93,8 @@
 let _ =
   CommonWeb.add_web_kind "guarding.p2p"
     "IP blocking lists (ipfilter and guardian v2 formats)"
-    (fun _ filename ->
-    try
+    (fun url filename ->
+    (try
       web_ip_blocking_list :=
        if filename = "" then
          Ip_set.bl_empty
@@ -102,10 +102,14 @@
          Ip_set.load filename;
       update_bans ()
     with _ -> ());
+    CommonWeb.remove_job url
+  );
   CommonWeb.add_web_kind "geoip.dat" "IP to country mapping database"
-    (fun _ filename ->
+    (fun url filename ->
     Geoip.init (Geoip.unpack filename);
-    update_bans ());
+    update_bans ();
+    CommonWeb.remove_job url
+  );
 
   Heap.add_memstat "CommonBlocking" (fun level buf ->
       Printf.bprintf buf "  local ranges: %d\n" 

Index: src/daemon/common/commonWeb.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonWeb.ml,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- src/daemon/common/commonWeb.ml      17 Jan 2007 18:51:41 -0000      1.38
+++ src/daemon/common/commonWeb.ml      17 Mar 2007 18:03:01 -0000      1.39
@@ -45,6 +45,21 @@
 let days = ref 0
 let hours = ref 0
 
+type web_jobs = {
+  mutable downloaded : bool;
+}
+
+let running_jobs = Hashtbl.create (List.length !!web_infos)
+
+let add_job url =
+  let wj = {
+    downloaded = false;
+  } in
+  Hashtbl.add running_jobs url wj
+
+let remove_job url =
+  Hashtbl.remove running_jobs url
+
 (*************************************************************************)
 (*                                                                       *)
 (*                         load_url                                      *)
@@ -59,6 +74,7 @@
 
   
 let mldonkey_wget_url url f =
+  add_job url;
   let module H = Http_client in
   let r = {
       H.basic_request with
@@ -91,7 +107,7 @@
     } in
     let date  = ref None in
     begin try
-    H.whead r1 (fun headers ->
+    H.whead2 r1 (fun headers ->
       List.iter (fun (name, content) ->
        if String.lowercase name = "last-modified" then
           try
@@ -125,7 +141,41 @@
                end
          end
       )
+      (fun c ->
+       match c with
+          | x when x < 200 || x > 299 -> begin
+            (* use local version if wget fail and file exists *)
+            let file = Filename.concat "web_infos" (Filename.basename 
r.H.req_url.Url.short_file) in
+            (try (* mark this job downloaded *)
+                (Hashtbl.find running_jobs url).downloaded <- true
+             with Not_found -> ());
+            if Sys.file_exists file then begin
+              lprintf_nl (_b "using local version of %s, HTTP request failed 
(error %d)") file x;
+              add_timer 5. (fun timer ->
+                let jobs =
+                  (* check if other jobs are still in downloading state to 
avoid calling
+                     function f, which might hurt other downloads for 
expensive functions *)
+                  let others_running = ref 0 in
+                  Hashtbl.iter (fun url j ->
+                    if not j.downloaded then others_running := succ 
!others_running
+                  ) running_jobs;
+                  !others_running
+                in
+                if jobs = 0 then
+                (* no other jobs in downloading state, process local versions 
of remotely failed job *)
+                  (f file : unit)
+                else
+                (* other jobs in downloading state, reactivate this timer to 
check again in 5s *)
+                  reactivate_timer timer
+                );
+              end
+            else
+              lprintf_nl (_b "local file %s not found, HTTP request failed 
(error %d)") file x;
+            end
+         | _ -> ()
+      )
     with e -> 
+      remove_job url;
       lprintf_nl (_b "Exception %s while loading %s")
         (Printexc2.to_string e) url
     end
@@ -160,13 +210,6 @@
       lprintf_nl (_b "Exception %s while loading %s")
           (Printexc2.to_string e) url
 
-let load_file kind file =
-  try
-    (List.assoc kind !file_kinds).f file file
-  with e ->
-      lprintf_nl (_b "Exception %s while loading kind %s")
-        (Printexc2.to_string e) kind
-
 (*************************************************************************)
 (*                                                                       *)
 (*                         load_web_infos                                *)
@@ -244,5 +287,6 @@
             feed
       in
       feed.rss_date <- last_time ();
-      feed.rss_value <- c
+      feed.rss_value <- c;
+      remove_job url
   )

Index: src/daemon/driver/driverMain.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverMain.ml,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -b -r1.137 -r1.138
--- src/daemon/driver/driverMain.ml     6 Mar 2007 19:31:26 -0000       1.137
+++ src/daemon/driver/driverMain.ml     17 Mar 2007 18:03:01 -0000      1.138
@@ -502,7 +502,7 @@
   Options.prune_file downloads_ini;
   Options.prune_file users_ini;
 (*  Options.prune_file downloads_expert_ini; *)
-  add_timer 5. (fun _ -> try CommonWeb.load_web_infos true false with _ -> ());
+  add_timer 1. (fun _ -> try CommonWeb.load_web_infos true false with _ -> ());
   lprintf_nl  (_b "To command: telnet %s %d")
        (if !!telnet_bind_addr = Ip.any then "127.0.0.1"
                else Ip.to_string !!telnet_bind_addr)  !!telnet_port;

Index: src/networks/donkey/donkeyInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyInteractive.ml,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -b -r1.150 -r1.151
--- src/networks/donkey/donkeyInteractive.ml    8 Mar 2007 21:01:02 -0000       
1.150
+++ src/networks/donkey/donkeyInteractive.ml    17 Mar 2007 18:03:01 -0000      
1.151
@@ -1930,12 +1930,8 @@
       if not !!enable_donkey then
         lprintf_nl "eDonkey module is disabled, ignoring..."
       else
-        lprintf_nl "ED2K-update_server_list_server_met is disabled, 
ignoring..."
-  );
-  CommonWeb.add_web_kind "comments.met" "List of edonkey files comments" 
-    (fun _ filename ->
-(* TODO      DonkeyIndexer.load_comments filename; *)
-      lprintf_nl "COMMENTS ADDED";
+        lprintf_nl "ED2K-update_server_list_server_met is disabled, 
ignoring...";
+    CommonWeb.remove_job url
   );
 
   file_ops.op_file_proposed_filenames <- op_file_proposed_filenames;

Index: src/networks/donkey/donkeyOvernet.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyOvernet.ml,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- src/networks/donkey/donkeyOvernet.ml        28 Feb 2007 22:24:58 -0000      
1.76
+++ src/networks/donkey/donkeyOvernet.ml        17 Mar 2007 18:03:01 -0000      
1.77
@@ -2069,7 +2069,7 @@
    end  
 
 let _ =
-  CommonWeb.add_web_kind web_info web_info_descr (fun _ filename ->
+  CommonWeb.add_web_kind web_info web_info_descr (fun url filename ->
       let s = File.to_string filename in
       let s = String2.replace s '"' "" in
       let lines = String2.split_simplify s '\n' in
@@ -2083,10 +2083,11 @@
                     let port = int_of_string port in
                     if !verbose_overnet then
                       lprintf_nl "Adding %s peer %s:%d" command_prefix_to_net 
name port;
-                    bootstrap ip port)
+                    bootstrap ip port) (fun _ -> ())
             | _ -> lprintf_nl "BAD LINE ocl: %s" s;
           with _ -> lprintf_nl "DNS failed";
-      ) lines
+      ) lines;
+  CommonWeb.remove_job url
   );
 
   (* Add this kind of web_info only for overnet *)
@@ -2100,7 +2101,8 @@
          if not !!enable_overnet then
       lprintf_nl "Overnet module is disabled, ignoring..."
          else
-      lprintf_nl "Overnet_update_nodes is disabled, ignoring..."
+      lprintf_nl "Overnet_update_nodes is disabled, ignoring...";
+      CommonWeb.remove_job url
         );
 
 (*************************************************************

Index: src/networks/fasttrack/fasttrackServers.ml
===================================================================
RCS file: 
/sources/mldonkey/mldonkey/src/networks/fasttrack/fasttrackServers.ml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- src/networks/fasttrack/fasttrackServers.ml  19 Sep 2006 17:07:43 -0000      
1.30
+++ src/networks/fasttrack/fasttrackServers.ml  17 Mar 2007 18:03:01 -0000      
1.31
@@ -84,11 +84,12 @@
     CommonWeb.add_web_kind "nodes.gzip" "List of fasttrack nodes"
     (fun url filename -> 
         lprintf_nl "nodes.gzip loaded from %s" url;
-        try
+        (try
           let f = unpack_nodes_gzip filename url in
           load_nodes_file f;
           if f <> filename then Sys.remove f;
-        with _ -> () 
+        with _ -> ());
+        CommonWeb.remove_job url
     )    
 
 let server_parse_after s gconn sock =

Index: src/utils/net/http_client.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/net/http_client.ml,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- src/utils/net/http_client.ml        11 Mar 2007 18:51:28 -0000      1.38
+++ src/utils/net/http_client.ml        17 Mar 2007 18:03:01 -0000      1.39
@@ -255,13 +255,8 @@
         TcpBufferedSocket.set_reader sock (http_reply_handler nread
             (default_headers_handler url level));
         set_rtimeout sock 5.;
-      (*
-        TcpBufferedSocket.set_closer sock (fun _ _ -> ()
-        lprintf "Connection closed nread:%b\n" !nread; 
-        )
-      *)
-
     )
+    ferr;
   with e -> 
     lprintf_nl "error in get_url"; 
     raise Not_found
@@ -363,6 +358,7 @@
     end
         else begin
           lprintf_nl "more than %d retries, aborting." r.req_max_retry;
+          ferr ans_code;
           raise Not_found
         end
           

Index: src/utils/net/ip.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/net/ip.ml,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- src/utils/net/ip.ml 27 Jul 2006 21:45:06 -0000      1.26
+++ src/utils/net/ip.ml 17 Mar 2007 18:03:01 -0000      1.27
@@ -285,6 +285,7 @@
     mutable entries : Unix.inet_addr array;
     mutable error : bool;
     handler : (t -> unit);
+    err_handler : (int -> unit);
   }
 
 
@@ -294,13 +295,13 @@
 let current_job = ref None
 let ip_fifo = Fifo.create ()
 
-let async_ip name f =
+let async_ip name f ferr =
   try
 (*    lprintf "async_ip [%s]\n" name; *)
     let ip = resolve_name_immediate name in
     (try f ip with _ -> ())
   with Not_found ->
-    Fifo.put ip_fifo (name, f)
+    Fifo.put ip_fifo (name, f, ferr)
 
 (* We check for names every 1/10 second. Too long ? *)
 let _ =
@@ -315,7 +316,7 @@
     while true do
       match !current_job with
       | None ->
-          let (name, f) = Fifo.take ip_fifo in
+          let (name, f, ferr) = Fifo.take ip_fifo in
           (try
            let ip = resolve_name_immediate name in
             (try f ip with _ -> ())
@@ -325,6 +326,7 @@
               BasicSocket.has_threads () then
                 let job = {
                   handler = f;
+                  err_handler = ferr;
                   name = name;
                   entries = [||];
                   error = false;
@@ -351,6 +353,7 @@
               job.handler ip
             end else begin
               lprintf_nl (_b "[DNS] could not resolve %s, check URL") job.name;
+              job.err_handler 0;
               raise Not_found
             end
           end else raise Exit
@@ -376,10 +379,10 @@
     AddrIp ip -> ip
   | AddrName name -> from_name name
 
-let async_ip_of_addr addr f =
+let async_ip_of_addr addr f ferr =
   match addr with
     AddrIp ip -> f ip
-  | AddrName name -> async_ip name f
+  | AddrName name -> async_ip name f ferr
 
 
 let value_to_addr v = addr_of_string (value_to_string v)

Index: src/utils/net/ip.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/net/ip.mli,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- src/utils/net/ip.mli        27 Jul 2006 21:45:06 -0000      1.8
+++ src/utils/net/ip.mli        17 Mar 2007 18:03:01 -0000      1.9
@@ -64,13 +64,13 @@
 val value_to_ip : Options.option_value -> t
 val ip_to_value : t -> Options.option_value
   
-val async_ip : string -> (t -> unit) -> unit
+val async_ip : string -> (t -> unit) -> (int -> unit) -> unit
   
 type addr =
   AddrIp of t | AddrName of string
   
 val ip_of_addr : addr -> t
-val async_ip_of_addr : addr -> (t -> unit) -> unit
+val async_ip_of_addr : addr -> (t -> unit) -> (int -> unit) -> unit
 val string_of_addr : addr -> string
 val addr_of_ip : t -> addr
 val addr_of_string : string -> addr




reply via email to

[Prev in Thread] Current Thread [Next in Thread]