[Top][All Lists]
[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: |
Sun, 19 Mar 2006 17:38:09 +0000 |
CVSROOT: /sources/mldonkey
Module name: mldonkey
Branch:
Changes by: spiralvoice <address@hidden> 06/03/19 17:38:08
Modified files:
distrib : ChangeLog
src/daemon/common: commonComplexOptions.ml
commonComplexOptions.mli commonInteractive.ml
commonOptions.ml
src/daemon/driver: driverCommands.ml driverInteractive.ml
driverMain.ml
Log message:
patch #4917
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/distrib/ChangeLog.diff?tr1=1.773&tr2=1.774&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonComplexOptions.ml.diff?tr1=1.49&tr2=1.50&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonComplexOptions.mli.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonInteractive.ml.diff?tr1=1.65&tr2=1.66&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonOptions.ml.diff?tr1=1.133&tr2=1.134&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml.diff?tr1=1.131&tr2=1.132&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverInteractive.ml.diff?tr1=1.68&tr2=1.69&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverMain.ml.diff?tr1=1.101&tr2=1.102&r1=text&r2=text
Patches:
Index: mldonkey/distrib/ChangeLog
diff -u mldonkey/distrib/ChangeLog:1.773 mldonkey/distrib/ChangeLog:1.774
--- mldonkey/distrib/ChangeLog:1.773 Sat Mar 18 18:35:12 2006
+++ mldonkey/distrib/ChangeLog Sun Mar 19 17:38:08 2006
@@ -14,6 +14,31 @@
ChangeLog
=========
+2006/03/19
+4917: HDD space check
+- New options:
+ hdd_send_warning_interval
+ Send a warning mail each <interval> hours for each directory,
+ 0 to deactivate mail warnings.
+
+ hdd_temp_minfree
+ Mininum free space in MB on temp_directory, minimum 50
+ hdd_temp_stop_core, default false
+ If true core shuts down when free space on temp dir is below
+ hdd_temp_minfree, otherwise all downloads are queued and a
+ warning email is sent.
+
+ hdd_coredir_minfree
+ Mininum free space in MB on core or log directory, minimum 20
+ hdd_coredir_stop_core, default true
+ If true core shuts down when free space on core dir is below
+ hdd_coredir_minfree, otherwise all ini file saving is stopped
+ until core shutdown and a warning email is sent.
+ Logging is sent to RAM when log dir is full.
+
+The hard-coded minimum values can not be circumvented, MLDonkey will always
+perform these HDD space checks once a minute.
+
2006/03/18
4985: Log file clean-up for verbosity = "md4"
Index: mldonkey/src/daemon/common/commonComplexOptions.ml
diff -u mldonkey/src/daemon/common/commonComplexOptions.ml:1.49
mldonkey/src/daemon/common/commonComplexOptions.ml:1.50
--- mldonkey/src/daemon/common/commonComplexOptions.ml:1.49 Wed Jan 25
22:29:53 2006
+++ mldonkey/src/daemon/common/commonComplexOptions.ml Sun Mar 19 17:38:08 2006
@@ -940,7 +940,10 @@
known_uids =:= [];
Options.load friends_ini
+let allow_saving_ini_files = ref true
+
let save () =
+ if !allow_saving_ini_files then begin
networks_iter (fun n -> network_save_complex_options n);
Options.save_with_help files_ini;
@@ -963,10 +966,13 @@
results =:= [];
end;
lprintf_nl () "Options correctly saved"
+ end
let save_sources () =
+ if !allow_saving_ini_files then begin
networks_iter (fun n -> network_save_sources n);
lprintf_nl () "Sources correctly saved"
+ end
open Zip
Index: mldonkey/src/daemon/common/commonComplexOptions.mli
diff -u mldonkey/src/daemon/common/commonComplexOptions.mli:1.16
mldonkey/src/daemon/common/commonComplexOptions.mli:1.17
--- mldonkey/src/daemon/common/commonComplexOptions.mli:1.16 Wed Jan 25
22:29:53 2006
+++ mldonkey/src/daemon/common/commonComplexOptions.mli Sun Mar 19 17:38:08 2006
@@ -21,6 +21,7 @@
val save : unit -> unit
val save_sources : unit -> unit
val backup_options : unit -> unit
+val allow_saving_ini_files : bool ref
val done_files : CommonTypes.file list Options.option_record
val files : CommonTypes.file list Options.option_record
Index: mldonkey/src/daemon/common/commonInteractive.ml
diff -u mldonkey/src/daemon/common/commonInteractive.ml:1.65
mldonkey/src/daemon/common/commonInteractive.ml:1.66
--- mldonkey/src/daemon/common/commonInteractive.ml:1.65 Wed Mar 15
20:54:00 2006
+++ mldonkey/src/daemon/common/commonInteractive.ml Sun Mar 19 17:38:08 2006
@@ -91,6 +91,40 @@
else
Buffer.contents buf
+let last_sent_dir_warning = Hashtbl.create 10
+
+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;
+ Pervasives.flush Pervasives.stderr;
+ if !!hdd_send_warning_interval <> 0 then
+ let current_time = last_time () in
+ let time_threshold =
+ current_time - !!hdd_send_warning_interval * Date.hour_in_secs in
+ let send_mail_again =
+ try
+ let last = Hashtbl.find last_sent_dir_warning dir in
+ last < time_threshold
+ with Not_found -> true in
+
+ if send_mail_again then begin
+ 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));
+ if !!mail <> "" then
+ let module M = Mailer in
+ let subject = Printf.sprintf "[mldonkey] AUTOMATED WARNING: %s is
full" dir in
+ let mail = {
+ M.mail_to = !!mail; M.mail_from = !!mail;
+ M.mail_subject = subject; M.mail_body = line1;
+ } in
+ try
+ M.sendmail !!smtp_server !!smtp_port !!add_mail_brackets mail
+ with _ -> ()
+ end
+
let file_commited_name incoming_dir file =
let best_name = file_best_name file in
(try Unix2.safe_mkdir incoming_dir with _ -> ());
@@ -158,39 +192,57 @@
name.
*)
+exception Incoming_full
+
let file_commit file =
let impl = as_file_impl file in
if impl.impl_file_state = FileDownloaded then
let subfiles = file_files file in
match subfiles with
file :: secondary_files ->
- let file_name = file_disk_name file in
- let incoming =
- if Unix2.is_directory file_name then
- incoming_directories ()
- else
- incoming_files ()
- in
- let new_name = file_commited_name
+ (try
+ let file_name = file_disk_name file in
+ let incoming =
+ if Unix2.is_directory file_name then
+ incoming_directories ()
+ else
+ incoming_files ()
+ in
+
+(* check if temp_directory and incoming are on different partitions *)
+ if (Unix.stat incoming.shdir_dirname).Unix.st_dev <>
+ (Unix.stat !!temp_directory).Unix.st_dev
+ then
+ begin
+ match Unix32.diskfree incoming.shdir_dirname with
+ Some v -> if v < (file_size file) then begin
+ send_dirfull_warning incoming.shdir_dirname
+ (Printf.sprintf "can not commit %s" (file_best_name
file));
+ raise Incoming_full
+ end
+ | _ -> ()
+ end;
+
+ let new_name = file_commited_name
incoming.shdir_dirname file in
- if Unix2.is_directory file_name then
- Unix2.safe_mkdir new_name;
- (try
+ if Unix2.is_directory file_name then begin
+ Unix2.safe_mkdir new_name;
+ Unix2.chmod new_name (Misc.int_of_octal_string !!create_dir_mask)
+ end;
+
(* the next line really moves the file *)
set_file_disk_name file new_name;
if !!file_completed_cmd <> "" then
script_for_file file incoming.shdir_dirname new_name;
- if Unix2.is_directory new_name then
- Unix2.chmod new_name (Misc.int_of_octal_string
!!create_dir_mask);
let best_name = file_best_name file in
Unix32.destroy (file_fd file);
+
if Unix2.is_directory file_name then Unix2.remove_all_directory
file_name;
- let impl = as_file_impl file in
-(* When the commit action is called, the file is supposed not to exist
-anymore. *)
+ let impl = as_file_impl file in
+(* When the commit action is called, the file is supposed not to exist
anymore. *)
impl.impl_file_ops.op_file_commit impl.impl_file_val new_name;
begin
@@ -220,7 +272,7 @@
with e ->
lprintf_nl () "Exception %s in file_commit secondaries"
(Printexc2.to_string e);
) secondary_files
- with e ->
+ with e ->
lprintf_nl () "Exception in file_commit: %s"
(Printexc2.to_string e))
| _ -> assert false
@@ -899,73 +951,84 @@
let force_download_quotas () =
let files = List.sort (fun f1 f2 ->
- let v = file_priority f2 - file_priority f1 in
- if v <> 0 then v else begin
- (**
- * [egs] do not start downloading
- * a small file against an already active download
- **)
- let d1 = file_downloaded f1 in
- let d2 = file_downloaded f2 in
- if (d1=0L ) && (d2 > 0L)
- then 1
- else if ( d2=0L ) && (d1 > 0L)
- then -1
- else begin
- (* Try to download in priority files with fewer bytes missing
- Rationale: once completed, it may allow to recover some disk
space *)
- let r1 = file_size f1 -- d1 in
- let r2 = file_size f2 -- d2 in
- if r1 = r2 then 0 else
- if r2 < r1 then 1 else -1
- end
- end
- )
- !!CommonComplexOptions.files in
-
+ let v = file_priority f2 - file_priority f1 in
+ if v <> 0 then v else
+ (**
+ * [egs] do not start downloading
+ * a small file against an already active download
+ **)
+ let d1 = file_downloaded f1 in
+ let d2 = file_downloaded f2 in
+ if d1 = 0L && d2 > 0L then 1
+ else
+ if d1 > 0L && d2 = 0L then -1
+ else
+ (* Try to download in priority files with fewer bytes missing
+ Rationale: once completed, it may allow to recover some disk
space *)
+ let r1 = file_size f1 -- d1 in
+ let r2 = file_size f2 -- d2 in
+ if r1 = r2 then 0 else
+ if r2 < r1 then 1 else -1
+ ) !!CommonComplexOptions.files in
+
+ (** move running and queued downloads from [list] to [files]
+ accumulator, until a drop of priority (or end of list) is
+ encountered; Then submit the batches of downloads with same
+ priority to [iter_line].
+
+ @param ndownloads number of running downloads no longer in [list]
+ @param nqueued number of queued downloads in [files]
+ *)
let rec iter list priority files ndownloads nqueued =
match list, files with
- [], [] -> ()
+ | [], [] -> ()
| [], _ ->
iter_line list priority files ndownloads nqueued
| f :: tail , _ :: _ when file_priority f < priority ->
iter_line list priority files ndownloads nqueued
| f :: tail, files ->
match file_state f with
- FileDownloading ->
+ | FileDownloading ->
iter tail (file_priority f) (f :: files) (ndownloads+1) nqueued
| FileQueued ->
iter tail (file_priority f) (f :: files) ndownloads (nqueued+1)
| _ ->
iter tail (file_priority f) files ndownloads nqueued
+ (** queue or unqueue downloads from [files] list to match quotas *)
and iter_line list priority files ndownloads nqueued =
if ndownloads > !!max_concurrent_downloads then
match files with
- [] -> assert false
+ | [] -> assert false
| f :: tail ->
match file_state f with
- FileDownloading ->
+ | FileDownloading ->
set_file_state f FileQueued;
iter_line list priority tail (ndownloads-1) nqueued
| _ -> iter_line list priority tail ndownloads (nqueued-1)
else
if ndownloads < !!max_concurrent_downloads && nqueued > 0 then
match files with
- [] -> assert false
+ | [] -> assert false
| f :: tail ->
match file_state f with
- FileQueued ->
+ | FileQueued ->
set_file_state f FileDownloading;
iter_line list priority tail (ndownloads+1) (nqueued-1)
| _ -> iter_line list priority tail ndownloads nqueued
else
- iter list priority [] ndownloads nqueued
+ iter list priority [] ndownloads 0
in
- iter files max_int [] 0 0
+ if not !all_temp_queued then
+ iter files max_int [] 0 0
+ else
+ List.iter (fun f ->
+ if file_state f = FileDownloading then
+ set_file_state f FileQueued
+ ) files
let _ =
option_hook max_concurrent_downloads (fun _ ->
- force_download_quotas ()
+ ignore (force_download_quotas ())
)
Index: mldonkey/src/daemon/common/commonOptions.ml
diff -u mldonkey/src/daemon/common/commonOptions.ml:1.133
mldonkey/src/daemon/common/commonOptions.ml:1.134
--- mldonkey/src/daemon/common/commonOptions.ml:1.133 Wed Mar 15 20:54:00 2006
+++ mldonkey/src/daemon/common/commonOptions.ml Sun Mar 19 17:38:08 2006
@@ -1084,6 +1084,26 @@
"Create new files as sparse, only valid on MinGW for files on NTFS drives"
bool_option true
+let hdd_temp_minfree = define_option current_section ["hdd_temp_minfree"]
+ "Mininum free space in MB on temp_directory, minimum 50" int_option 50
+
+let hdd_temp_stop_core = define_option current_section ["hdd_temp_stop_core"]
+ "If true core shuts down when free space on temp dir is below
hdd_temp_minfree,
+ otherwise all downloads are paused and a warning email is sent."
+ bool_option false
+
+let hdd_coredir_minfree = define_option current_section ["hdd_coredir_minfree"]
+ "Mininum free space in MB on core directory, minimum 20" int_option 50
+
+let hdd_coredir_stop_core = define_option current_section
["hdd_coredir_stop_core"]
+ "If true core shuts down when free space on core dir is below
hdd_coredir_minfree,
+ otherwise all downloads are paused and a warning email is sent."
+ bool_option true
+
+let hdd_send_warning_interval = define_option current_section
["hdd_send_warning_interval"]
+ "Send a warning mail each <interval> hours for each directory, 0 to
deactivate mail warnings."
+ int_option 1
+
let previewer = define_expert_option current_section ["previewer"]
"Name of program used for preview (first arg is local filename, second arg
is name of file as searched on eDonkey" string_option
@@ -1611,6 +1631,12 @@
option_hook log_size (fun _ ->
lprintf_max_size := !!log_size
);
+ option_hook hdd_temp_minfree (fun _ ->
+ if !!hdd_temp_minfree < 50 then
+ hdd_temp_minfree =:= 50);
+ option_hook hdd_coredir_minfree (fun _ ->
+ if !!hdd_coredir_minfree < 20 then
+ hdd_coredir_minfree =:= 20);
option_hook compaction_overhead (fun _ ->
let gc_control = Gc.get () in
Gc.set { gc_control with Gc.max_overhead = !!compaction_overhead };
Index: mldonkey/src/daemon/driver/driverCommands.ml
diff -u mldonkey/src/daemon/driver/driverCommands.ml:1.131
mldonkey/src/daemon/driver/driverCommands.ml:1.132
--- mldonkey/src/daemon/driver/driverCommands.ml:1.131 Fri Mar 17 18:51:54 2006
+++ mldonkey/src/daemon/driver/driverCommands.ml Sun Mar 19 17:38:08 2006
@@ -1734,6 +1734,11 @@
[
strings_of_option previewer;
strings_of_option temp_directory;
+ strings_of_option hdd_temp_minfree;
+ strings_of_option hdd_temp_stop_core;
+ strings_of_option hdd_coredir_minfree;
+ strings_of_option hdd_coredir_stop_core;
+ strings_of_option hdd_send_warning_interval;
strings_of_option file_started_cmd;
strings_of_option file_completed_cmd;
strings_of_option allow_browse_share;
@@ -1978,6 +1983,10 @@
| Some p -> Printf.sprintf "%d%%" p in
Printf.bprintf buf "percentused %s\n" (print_percento
(Unix32.percentused arg));
Printf.bprintf buf "percentfree %s\n" (print_percento
(Unix32.percentfree arg));
+ let stat = Unix.stat arg in
+ Printf.bprintf buf "\nstat_device %d\n" stat.Unix.st_dev;
+ Printf.bprintf buf "stat_inode %d\n" stat.Unix.st_ino;
+
_s ""
), "debug command (example: disk .)";
Index: mldonkey/src/daemon/driver/driverInteractive.ml
diff -u mldonkey/src/daemon/driver/driverInteractive.ml:1.68
mldonkey/src/daemon/driver/driverInteractive.ml:1.69
--- mldonkey/src/daemon/driver/driverInteractive.ml:1.68 Fri Mar 17
18:33:16 2006
+++ mldonkey/src/daemon/driver/driverInteractive.ml Sun Mar 19 17:38:08 2006
@@ -82,7 +82,49 @@
let real_startup_message () =
!startup_message ^ (verify_user_admin ()) ^ (check_supported_os ())
^ (if not !dns_works then "DNS resolution does not work" else "")
-
+
+let hdd_check () =
+ let dir_full dir mb =
+ match Unix32.diskfree dir with
+ | None -> false
+ | Some v -> v < megabytes mb
+ in
+
+ 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...";
+ CommonInteractive.clean_exit 0
+ end
+ else begin
+ send_dirfull_warning !!temp_directory "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 _ -> ()
+ 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...";
+ 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
+ end
+ else
+ allow_saving_ini_files := true;
+
+ 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...";
+ close_log ()
+ end
+
(* ripped from gui_downloads *)
let calc_file_eta f =
@@ -228,6 +270,7 @@
Printf2.lprintf "Exception %s while flushing\n" (Printexc2.to_string e)
);
if !initialization_completed then (
+ if !allow_saving_ini_files then begin
Options.save_with_help downloads_ini;
Options.save_with_help_private users_ini;
CommonComplexOptions.save ();
@@ -236,6 +279,7 @@
List.iter (fun opfile ->
Options.save_with_help opfile
) r.network_config_file);
+ end
) else (
Printf2.lprintf "Initialization not completed, bypassing state saving\n"
);
Index: mldonkey/src/daemon/driver/driverMain.ml
diff -u mldonkey/src/daemon/driver/driverMain.ml:1.101
mldonkey/src/daemon/driver/driverMain.ml:1.102
--- mldonkey/src/daemon/driver/driverMain.ml:1.101 Wed Mar 15 20:54:00 2006
+++ mldonkey/src/daemon/driver/driverMain.ml Sun Mar 19 17:38:08 2006
@@ -68,19 +68,15 @@
incr CommonWeb.days
let minute_timer () =
+ DriverInteractive.hdd_check ();
CommonShared.shared_check_files ();
CommonUploads.upload_credit_timer ();
CommonInteractive.force_download_quotas ();
CommonResult.dummy_result.result_time <- last_time ();
(try
Int64Swarmer.verify_some_chunks ()
- with _ -> ()
- );
- CommonClient.clear_upload_slots ();
- if !!auto_commit then
- List.iter (fun file ->
- file_commit file
- ) !!CommonComplexOptions.done_files
+ with _ -> ());
+ CommonClient.clear_upload_slots ()
let hourly_timer timer =
incr CommonWeb.hours;
@@ -92,6 +88,11 @@
DriverControlers.check_calendar ();
CommonFile.propose_filenames ()
+let ten_second_timer timer =
+ if !!auto_commit then
+ List.iter (fun file ->
+ file_commit file
+ ) !!CommonComplexOptions.done_files
let second_timer timer =
(try
@@ -276,7 +277,8 @@
(try
Options.load downloads_ini;
Options.load users_ini;
- ignore (DriverInteractive.verify_user_admin ())
+ ignore (DriverInteractive.verify_user_admin ());
+ DriverInteractive.hdd_check ()
with e ->
lprintf_nl () "Exception %s during options load" (Printexc2.to_string
e);
exit 70);
@@ -474,6 +476,7 @@
start_interfaces ();
add_infinite_timer 60. minute_timer;
+ add_infinite_timer 10. ten_second_timer;
add_infinite_timer 3600. hourly_timer;
add_infinite_timer 0.1 CommonUploads.upload_download_timer;
@@ -656,6 +659,7 @@
(* In case we have no more space on filesystem for
config files, remove the security space file *)
Sys.remove security_space_filename;
+ CommonComplexOptions.allow_saving_ini_files := true;
DriverInteractive.save_config ();
CommonComplexOptions.save_sources ();
CommonComplexOptions.backup_options ();
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/05
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/05
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/06
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/08
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/15
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/17
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/17
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...,
mldonkey-commits <=
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/29
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/03/31