[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: |
Wed, 15 Nov 2006 12:37:13 +0000 |
CVSROOT: /sources/mldonkey
Module name: mldonkey
Changes by: spiralvoice <spiralvoice> 06/11/15 12:37:13
Modified files:
distrib : ChangeLog
src/daemon/common: commonFile.ml commonOptions.ml commonWeb.ml
src/daemon/driver: driverCommands.ml
Log message:
patch #5556
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1096&r2=1.1097
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonFile.ml?cvsroot=mldonkey&r1=1.69&r2=1.70
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonOptions.ml?cvsroot=mldonkey&r1=1.186&r2=1.187
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonWeb.ml?cvsroot=mldonkey&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverCommands.ml?cvsroot=mldonkey&r1=1.196&r2=1.197
Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1096
retrieving revision 1.1097
diff -u -b -r1.1096 -r1.1097
--- distrib/ChangeLog 15 Nov 2006 12:34:30 -0000 1.1096
+++ distrib/ChangeLog 15 Nov 2006 12:37:13 -0000 1.1097
@@ -15,6 +15,8 @@
=========
2006/11/15
+5556: web_infos: new option rss_preprocessor used for fixing broken RSS feeds,
+ safer process spawning for command "!" (pango)
5560: EDK: Parse some more server.met fields, log unknown server tags
2006/11/14
Index: src/daemon/common/commonFile.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonFile.ml,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -b -r1.69 -r1.70
--- src/daemon/common/commonFile.ml 12 Nov 2006 12:44:24 -0000 1.69
+++ src/daemon/common/commonFile.ml 15 Nov 2006 12:37:13 -0000 1.70
@@ -552,9 +552,10 @@
impl.impl_file_last_seen <- age
let file_preview (file : file) =
- let cmd = Printf.sprintf "%s \"%s\" \"%s\"" !!previewer
- (file_disk_name file) (file_best_name file) in
- ignore (Sys.command cmd)
+ ignore(
+ Unix.create_process !!previewer
+ [| Filename2.basename !!previewer; file_disk_name file; file_best_name
file |]
+ Unix.stdin Unix.stdout Unix.stderr)
(*************************************************************************)
(* *)
Index: src/daemon/common/commonOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonOptions.ml,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -b -r1.186 -r1.187
--- src/daemon/common/commonOptions.ml 14 Nov 2006 11:23:11 -0000 1.186
+++ src/daemon/common/commonOptions.ml 15 Nov 2006 12:37:13 -0000 1.187
@@ -1023,6 +1023,10 @@
"URLs of RSS feeds"
(list_option Url.option) []
+let rss_preprocessor = define_expert_option current_section
["rss_preprocessor"]
+ "If MLDonkey can not read broken RSS feeds, use this program to preprocess
them"
+ string_option "xmllint"
+
let ip_blocking_descriptions = define_expert_option current_section
["ip_blocking_descriptions"]
"Keep IP blocking ranges descriptions in memory"
bool_option false
Index: src/daemon/common/commonWeb.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonWeb.ml,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- src/daemon/common/commonWeb.ml 14 Nov 2006 20:04:11 -0000 1.35
+++ src/daemon/common/commonWeb.ml 15 Nov 2006 12:37:13 -0000 1.36
@@ -192,13 +192,47 @@
let rss_feeds = Hashtbl.create 10
-
let _ =
add_web_kind "rss" "Syndication feeds to get periodically updated data"
(fun url filename ->
lprintf_nl (_b "parsing feed %s (rss)") url;
- let c = Rss.channel_of_file filename in
+ let c =
+ (try
+ let rss_c = Rss.channel_of_file filename in
(try Sys.remove filename with _ -> ());
+ rss_c
+ with Xml.Error _ ->
+ lprintf_nl (_b "found buggy feed, preprocessing with %s and trying
again") !!rss_preprocessor;
+ (try
+ let pipe_out, pipe_in = Unix.pipe () in
+ let pid = Unix.create_process !!rss_preprocessor [|
!!rss_preprocessor; filename |]
+ Unix.stdin pipe_in pipe_in in
+ Unix.close pipe_in;
+ let output = Buffer.create 1024 in
+ let buffersize = 1024 in
+ let buffer = String.create buffersize in
+ (try
+ while true do
+ let nread = Unix.read pipe_out buffer 0 buffersize in
+ if nread = 0 then raise End_of_file;
+ Buffer.add_substring output buffer 0 nread
+ done
+ with
+ | End_of_file -> ()
+ | Unix.Unix_error (code, f, arg) ->
+ lprintf_nl "%s failed: %s" !!rss_preprocessor
(Unix.error_message code));
+ (try Unix.close pipe_out with _ -> ());
+ (try Sys.remove filename with _ -> ());
+ let _pid, _ = Unix.waitpid [] pid in
+ let result = Buffer.contents output in
+ if result = "" then begin
+ lprintf_nl (_b "%s produced empty content for feed %s, program
missing?") !!rss_preprocessor url;
+ raise Not_found
+ end;
+ Rss.channel_of_string result
+ with Unix.Unix_error (code, f, arg) ->
+ lprintf_nl (_b "%s failed: %s") !!rss_preprocessor
(Unix.error_message code); raise Not_found))
+ in
let feed =
try Hashtbl.find rss_feeds url with
Not_found ->
Index: src/daemon/driver/driverCommands.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml,v
retrieving revision 1.196
retrieving revision 1.197
diff -u -b -r1.196 -r1.197
--- src/daemon/driver/driverCommands.ml 14 Nov 2006 11:25:05 -0000 1.196
+++ src/daemon/driver/driverCommands.ml 15 Nov 2006 12:37:13 -0000 1.197
@@ -1104,16 +1104,43 @@
"!", Arg_multiple (fun arg o ->
if !!allow_any_command then
match arg with
- c :: tail ->
- let args = String2.unsplit tail ' ' in
+ c :: args ->
let cmd = try List.assoc c !!allowed_commands with Not_found ->
c in
- let tmp = Filename.temp_file "com" ".out" in
- let ret = Sys.command (Printf.sprintf "%s %s > %s"
- cmd args tmp) in
- let output = File.to_string tmp in
- Sys.remove tmp;
- Printf.sprintf (_b "%s\n---------------- Exited with code %d")
output ret
- | _ -> _s "no command given"
+ (try
+ let pipe_out, pipe_in = Unix.pipe () in
+ let pid = Unix.create_process cmd
+ (Array.of_list (Filename2.basename c :: args))
+ Unix.stdin pipe_in pipe_in in
+ Unix.close pipe_in;
+ (* can't close pipe_out in the already forked+executed
process... *)
+ let output = Buffer.create 1024 in
+ let buffersize = 1024 in
+ let buffer = String.create buffersize in
+ (try
+ while true do
+ let nread = Unix.read pipe_out buffer 0 buffersize in
+ if nread = 0 then raise End_of_file;
+ Buffer.add_substring output buffer 0 nread
+ done
+ with
+ | End_of_file -> ()
+ | Unix.Unix_error (code, f, arg) ->
+ lprintf_nl "%s failed%s: %s" f (if arg = "" then "" else
" on " ^ arg) (Unix.error_message code));
+ (try Unix.close pipe_out with _ -> ());
+ let _pid, status = Unix.waitpid [] pid in
+ Printf.sprintf (_b "%s\n---------------- %s")
+ (Buffer.contents output)
+ (match status with
+ | Unix.WEXITED exitcode ->
+ Printf.sprintf "Exited with code %d" exitcode
+ | Unix.WSIGNALED signal ->
+ Printf.sprintf "Was killed by signal %d" signal
+ | Unix.WSTOPPED signal -> (* does it matter for us ? *)
+ Printf.sprintf "Was stopped by signal %d" signal)
+
+ with Unix.Unix_error (code, f, arg) ->
+ Printf.sprintf "%s failed%s: %s" f (if arg = "" then "" else "
on " ^ arg) (Unix.error_message code))
+ | [] -> _s "no command given"
else
match arg with
[arg] ->
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., (continued)
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/05
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/12
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/12
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/12
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/13
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/13
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/14
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...,
mldonkey-commits <=
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/19
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/19
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/21
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/26
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/26
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/28
- [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co..., mldonkey-commits, 2006/11/28