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: Fri, 14 Jul 2006 14:23:37 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       06/07/14 14:23:37

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonInteractive.ml 
        src/daemon/driver: driverCommands.ml driverInteractive.ml 
                           driverMain.ml 
        src/utils/cdk  : printf2.ml printf2.mli 

Log message:
        patch #5222

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.913&r2=1.914
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonInteractive.ml?cvsroot=mldonkey&r1=1.74&r2=1.75
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverCommands.ml?cvsroot=mldonkey&r1=1.159&r2=1.160
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverInteractive.ml?cvsroot=mldonkey&r1=1.89&r2=1.90
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverMain.ml?cvsroot=mldonkey&r1=1.117&r2=1.118
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/cdk/printf2.ml?cvsroot=mldonkey&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/cdk/printf2.mli?cvsroot=mldonkey&r1=1.6&r2=1.7

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.913
retrieving revision 1.914
diff -u -b -r1.913 -r1.914
--- distrib/ChangeLog   14 Jul 2006 13:26:48 -0000      1.913
+++ distrib/ChangeLog   14 Jul 2006 14:23:37 -0000      1.914
@@ -15,6 +15,7 @@
 =========
 
 2006/07/14
+5222: Improve log output when HDD is full
 5214: Gettext: Improve translations
 * added ./distrib/i18n/mlnet_strings.de_DE.utf8 for testing purposes
   startup messages should appear in German now, more strings have

Index: src/daemon/common/commonInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonInteractive.ml,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -b -r1.74 -r1.75
--- src/daemon/common/commonInteractive.ml      14 Jul 2006 13:24:23 -0000      
1.74
+++ src/daemon/common/commonInteractive.ml      14 Jul 2006 14:23:37 -0000      
1.75
@@ -91,12 +91,16 @@
 
 let last_sent_dir_warning = Hashtbl.create 10
 
+let hdd_full_log_closed = ref false
 let all_temp_queued = ref false
 
-let send_dirfull_warning dir line1 =
-  lprintf_nl "WARNING: Directory %s is full, %s" dir line1;
-  Printf.fprintf Pervasives.stderr "\nWARNING: Directory %s is full, %s\n" dir 
line1;
+let send_dirfull_warning dir full line1 =
+  let status = if full then "is full" else "has enough space again" in
+  lprintf_nl "WARNING: Directory %s %s, %s" dir status line1;
+  if (not (keep_console_output ())) then begin
+    Printf.fprintf Pervasives.stderr "\n%s WARNING: Directory %s %s, %s\n" 
(log_time ()) dir status line1;
   Pervasives.flush Pervasives.stderr;
+  end;
   if !!hdd_send_warning_interval <> 0 then
     let current_time = last_time () in
     let time_threshold =
@@ -108,12 +112,12 @@
       with Not_found -> true in
 
     if send_mail_again then begin
-      Hashtbl.replace last_sent_dir_warning dir current_time;
+      if full then Hashtbl.replace last_sent_dir_warning dir current_time;
       CommonEvent.add_event (Console_message_event
-        (Printf.sprintf "\nWARNING: %s is full, %s\n" dir line1));
+        (Printf.sprintf "\nWARNING: %s %s, %s\n" dir status line1));
       if !!mail <> "" then
         let module M = Mailer in
-        let subject = Printf.sprintf "[mldonkey] AUTOMATED WARNING: %s is 
full" dir in
+        let subject = Printf.sprintf "address@hidden AUTOMATED WARNING: %s %s" 
(Unix.gethostname ()) dir status in
         let mail = {
           M.mail_to = !!mail; M.mail_from = !!mail;
          M.mail_subject = subject; M.mail_body = line1;
@@ -216,7 +220,7 @@
            begin
              match Unix32.diskfree incoming.shdir_dirname with
                Some v -> if v < (file_size file) then begin
-                   send_dirfull_warning incoming.shdir_dirname
+                   send_dirfull_warning incoming.shdir_dirname true
                      (Printf.sprintf "can not commit %s" (file_best_name 
file));
                    raise Incoming_full
                  end
@@ -322,9 +326,9 @@
     in
 
     let subject = if !!filename_in_subject then
-        Printf.sprintf "[mldonkey] file received - %s" (file_best_name file)
+        Printf.sprintf "address@hidden file received - %s" (Unix.gethostname 
()) (file_best_name file)
       else
-        Printf.sprintf "mldonkey, file received"
+        Printf.sprintf "address@hidden, file received" (Unix.gethostname ())
     in
 
     let incoming =

Index: src/daemon/driver/driverCommands.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -b -r1.159 -r1.160
--- src/daemon/driver/driverCommands.ml 27 Jun 2006 21:20:28 -0000      1.159
+++ src/daemon/driver/driverCommands.ml 14 Jul 2006 14:23:37 -0000      1.160
@@ -1353,6 +1353,7 @@
     ), "<option_name> <option_value> :\t$bchange option value$n";
 
     "save", Arg_multiple (fun args o ->
+       if !allow_saving_ini_files then begin
         match args with
          ["options"] -> DriverInteractive.save_config (); _s "options saved"
        | ["sources"] -> CommonComplexOptions.save_sources (); _s "sources 
saved"
@@ -1364,6 +1365,7 @@
                _s "options, sources and backup saved"
        | _ -> DriverInteractive.save_config ();
               CommonComplexOptions.save_sources (); _s "options and sources 
saved"
+       end else _s "base directory full, ini file saving disabled until core 
shutdown"
         ), "[<options|sources|backup>] :\tsave options and/or sources or 
backup (empty for options and sources)";
 
     "vo", Arg_none (fun o ->
@@ -2919,9 +2921,7 @@
     "<width> <height> :\t\t\tset terminal width and height (devel)";
 
     "stdout", Arg_one (fun arg o ->
-        let b = bool_of_string arg in
-        set_logging b;
-       if b then
+       if (bool_of_string arg) then
          begin
       lprintf_nl "Enable logging to stdout...";
            log_to_file stdout;
@@ -2939,7 +2939,7 @@
              end
          end;
         Printf.sprintf (_b "log to stdout %s")
-        (if b then _s "enabled" else _s "disabled")
+        (if (bool_of_string arg) then _s "enabled" else _s "disabled")
     ), "<true|false> :\t\t\treactivate log to stdout";
 
     "debug_client", Arg_multiple (fun args o ->

Index: src/daemon/driver/driverInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverInteractive.ml,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -b -r1.89 -r1.90
--- src/daemon/driver/driverInteractive.ml      14 Jul 2006 13:24:24 -0000      
1.89
+++ src/daemon/driver/driverInteractive.ml      14 Jul 2006 14:23:37 -0000      
1.90
@@ -82,9 +82,12 @@
 let real_startup_message () =
   let s =
   !startup_message ^ (verify_user_admin ()) ^ (check_supported_os ()) 
-  ^ (if not !dns_works then "DNS resolution does not work" else "")
+  ^ (if not !dns_works then "DNS resolution does not work\n" else "")
+  ^ (if not !allow_saving_ini_files then "Base directory is full, ini file 
saving disabled\n" else "")
+  ^ (if !all_temp_queued then "Temp directory is full, all downloads are 
queued\n" else "")
+  ^ (if !hdd_full_log_closed then "Logfile directory is full, logging 
redirected to RAM\n" else "")
   ^ (if Autoconf.donkey = "yes" && not !!enable_servers && !!enable_donkey then
-     "You disabled option enable_servers, you will not be able to connect to 
ED2K servers"
+     "You disabled option enable_servers, you will not be able to connect to 
ED2K servers\n"
      else "")
   in
   if s = "" then None else Some s
@@ -99,38 +102,63 @@
 
   if dir_full !!temp_directory !!hdd_temp_minfree then
     if !!hdd_temp_stop_core then begin
-      send_dirfull_warning !!temp_directory "MLDonkey temp directory partition 
full, shutting down...";
+      send_dirfull_warning !!temp_directory true "MLDonkey shuts down";
       CommonInteractive.clean_exit 0
       end
     else begin
-      send_dirfull_warning !!temp_directory "MLDonkey queues all downloads";
+      send_dirfull_warning !!temp_directory true "MLDonkey queues all 
downloads";
       all_temp_queued := true
     end
   else
     begin
       all_temp_queued := false;
-      try Hashtbl.remove last_sent_dir_warning !!temp_directory with _ -> ()
+      try
+       ignore (Hashtbl.find last_sent_dir_warning !!temp_directory);
+        (try Hashtbl.remove last_sent_dir_warning !!temp_directory with 
Not_found -> ());
+        send_dirfull_warning !!temp_directory false "MLDonkey unqueues all 
downloads"
+      with Not_found -> ()
     end;
 
   let core_dir = Sys.getcwd () in
   if dir_full core_dir !!hdd_coredir_minfree then
     if !!hdd_coredir_stop_core then begin
-      send_dirfull_warning core_dir "MLDonkey base directory partition full, 
shutting down...";
+      send_dirfull_warning core_dir true "MLDonkey shuts down";
       CommonInteractive.clean_exit 0
       end
     else
       begin
-        send_dirfull_warning core_dir "MLDonkey base directory partition full, 
stop saving ini files...";
-        allow_saving_ini_files := false
+        allow_saving_ini_files := false;
+        send_dirfull_warning core_dir true "MLDonkey base directory partition 
full, stop saving ini files"
       end
   else
+    begin
     allow_saving_ini_files := true;
+      try
+       ignore (Hashtbl.find last_sent_dir_warning core_dir);
+        (try Hashtbl.remove last_sent_dir_warning core_dir with Not_found -> 
());
+        send_dirfull_warning core_dir false "MLDonkey base directory partition 
has enough free space again, saving ini files again"
+      with Not_found -> ()
+    end;
 
+  if !!log_file <> "" && (not (keep_console_output ())) then begin
   let log_dir = Filename.dirname !!log_file in
-  if dir_full log_dir !!hdd_coredir_minfree then begin
-    send_dirfull_warning log_dir "MLDonkey logdirectory partition full, 
redirect log to RAM...";
+  if dir_full log_dir !!hdd_coredir_minfree then
+    begin
+      hdd_full_log_closed := true;
+      send_dirfull_warning log_dir true "MLDonkey logdirectory partition full, 
redirect log to RAM";
     close_log ()
   end
+  else
+    begin
+      if !hdd_full_log_closed then log_file =:= !!log_file;
+      hdd_full_log_closed := false;
+      try
+       ignore (Hashtbl.find last_sent_dir_warning log_dir);
+        (try Hashtbl.remove last_sent_dir_warning log_dir with Not_found -> 
());
+        send_dirfull_warning log_dir false "MLDonkey logdirectory partition 
has enough free space again, re-enabling logging"
+      with Not_found -> ()
+    end
+  end
 
 (* ripped from gui_downloads *)
 

Index: src/daemon/driver/driverMain.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverMain.ml,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -b -r1.117 -r1.118
--- src/daemon/driver/driverMain.ml     14 Jul 2006 13:24:24 -0000      1.117
+++ src/daemon/driver/driverMain.ml     14 Jul 2006 14:23:37 -0000      1.118
@@ -47,8 +47,6 @@
 let lprintf_n fmt =
   lprintf2 log_prefix fmt
 
-
-let keep_console_output = ref false
 let pid = ref ""
 
 let do_daily () =
@@ -282,13 +280,13 @@
           exit 0),
       _s " : display information on the implementations";
       "-stdout", Arg.Unit (fun _ ->
-          keep_console_output := true;
-          log_to_file stdout;
+         lprintf_original_output := (Some stdout);
+          log_to_file stdout
       ),
        _s ": keep output to stdout after startup";
        "-stderr", Arg.Unit (fun _ ->
-           keep_console_output := true;
-           log_to_file stderr;
+         lprintf_original_output := (Some stderr);
+          log_to_file stderr
        ),
        _s ": keep output to stderr after startup";
       "-daemon", Arg.Unit (fun _ ->
@@ -308,7 +306,7 @@
 (*      Files.dump_file file; exit 0 *)
   ) "";
 
-  if not ini_files_exist && not !keep_console_output then log_file =:= 
"mlnet.log";
+  if not ini_files_exist && not (keep_console_output ()) then log_file =:= 
"mlnet.log";
 
   (**** CREATE DIRS   ****)
 
@@ -454,7 +452,7 @@
        (if !!gui_bind_addr = Ip.any then "127.0.0.1"
                else Ip.to_string !!gui_bind_addr)  !!gui_port;
   lprintf_nl  (_b "If you connect from a remote machine adjust allowed_ips");
-  if Autoconf.system = "cygwin" && not !keep_console_output then lprintf (_b 
"%s") win_message;
+  if Autoconf.system = "cygwin" && not (keep_console_output ()) then lprintf 
(_b "%s") win_message;
 
   add_init_hook (fun _ ->
       if not !gui_included && ( !!start_gui || !!ask_for_gui ) then
@@ -576,7 +574,7 @@
 
 (* When a core is spawned from a gui, the only way to know the startup has
    succeeded is the string token "Core started". *)
-  if not !keep_console_output then
+  if not (keep_console_output ()) then
     begin
       try
         Printf.fprintf Pervasives.stderr "%sCore started\n" (log_time ());
@@ -613,7 +611,7 @@
       lprintf_nl (_b "Core stopped")
     );
 
-  if not !keep_console_output then
+  if not (keep_console_output ()) then
     if !!log_file = "" then 
       begin
         lprintf_nl (_b "Option log_file is empty, disable logging 
completely...");

Index: src/utils/cdk/printf2.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/cdk/printf2.ml,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- src/utils/cdk/printf2.ml    19 May 2006 23:43:55 -0000      1.17
+++ src/utils/cdk/printf2.ml    14 Jul 2006 14:23:37 -0000      1.18
@@ -221,14 +221,21 @@
 let lprintf_max_size = ref 100
 let lprintf_size = ref 0
 let lprintf_fifo = Fifo.create ()
-let lprintf_to_stdout = ref true
+let lprintf_to_channel = ref true
 
 let lprintf_output = ref (Some stderr)
+let lprintf_original_output = ref None
+
+let keep_console_output () =
+  match !lprintf_original_output with
+    Some stdout -> true
+  | Some stderr -> true
+  | _ -> false
 
 let _ =
   set_lprintf_handler (fun s ->
       match !lprintf_output with
-        Some out when !lprintf_to_stdout ->
+        Some out when !lprintf_to_channel ->
           Printf.fprintf out "%s" s; flush out
       | _ ->
           if !lprintf_size >= !lprintf_max_size then
@@ -244,7 +251,7 @@
   | _ -> ()
 
 let close_log () =
-  lprintf_to_stdout := false;
+  lprintf_to_channel := false;
   match !lprintf_output with
     None -> ()
   | Some oc ->
@@ -255,7 +262,7 @@
 let log_to_file oc =
   close_log ();
   lprintf_output := Some oc;
-  lprintf_to_stdout := true
+  lprintf_to_channel := true
 
 let log_to_buffer buf =
   try
@@ -266,9 +273,6 @@
     done
   with _ -> ()
 
-let set_logging b =
-  lprintf_to_stdout := b
-
 (* html_mods *)
 
 let html_mods_commands buf n c l =

Index: src/utils/cdk/printf2.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/cdk/printf2.mli,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- src/utils/cdk/printf2.mli   19 May 2006 23:43:55 -0000      1.6
+++ src/utils/cdk/printf2.mli   14 Jul 2006 14:23:37 -0000      1.7
@@ -19,6 +19,9 @@
 
 open Autoconf
 
+val lprintf_original_output : out_channel option ref
+val keep_console_output : unit -> bool
+
 val log_time : unit -> string
 val cprintf : (string -> unit) -> ('a, unit, unit) format -> 'a
 (** [cprintf k format arguments] is the same as [printf format arguments],
@@ -33,21 +36,11 @@
 val lprint_char : char -> unit  
 val lprint_string : string -> unit  
 val lprint_int : int -> unit  
-
-(*
-val lprintf_to_stdout : bool ref  
-val lprintf_fifo : string Fifo.t
-val lprintf_max_size : int ref
-val lprintf_output : out_channel option ref
-val set_lprintf_handler : (string -> unit) -> unit
-*)
-
 val lprintf_max_size : int ref
   
 val detach : unit -> unit
 val log_to_file : out_channel -> unit
 val log_to_buffer : Buffer.t -> unit
-val set_logging : bool -> unit
 val close_log : unit -> unit
 
 val html_mods_big_header_start : Buffer.t -> string -> string list -> unit




reply via email to

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