[Pkg-ocaml-maint-commits] r2898 - in
/trunk/packages/mldonkey/trunk/debian: changelog patches/00list
patches/03_lock_config_files_space.dpatch
smimram at users.alioth.debian.org
smimram at users.alioth.debian.org
Mon Jul 10 22:40:13 UTC 2006
Author: smimram
Date: Mon Jul 10 22:40:11 2006
New Revision: 2898
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/?sc=1&rev=2898
Log:
Added 03_lock_config_files_space.dpatch.
Added:
trunk/packages/mldonkey/trunk/debian/patches/03_lock_config_files_space.dpatch (with props)
Modified:
trunk/packages/mldonkey/trunk/debian/changelog
trunk/packages/mldonkey/trunk/debian/patches/00list
Modified: trunk/packages/mldonkey/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/mldonkey/trunk/debian/changelog?rev=2898&op=diff
==============================================================================
--- trunk/packages/mldonkey/trunk/debian/changelog (original)
+++ trunk/packages/mldonkey/trunk/debian/changelog Mon Jul 10 22:40:11 2006
@@ -1,5 +1,7 @@
mldonkey (2.7.7-3) UNRELEASED; urgency=low
+ * Added 03_lock_config_files_space.dpatch in order to handle leftover
+ config_files_space.tmp files, closes: #359237.
* Removed obsolete configure options, closes: #375921. Also removed Soulseek
and Opennap from the description.
* Updated french debconf templates translation, closes: #377574.
Modified: trunk/packages/mldonkey/trunk/debian/patches/00list
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/mldonkey/trunk/debian/patches/00list?rev=2898&op=diff
==============================================================================
--- trunk/packages/mldonkey/trunk/debian/patches/00list (original)
+++ trunk/packages/mldonkey/trunk/debian/patches/00list Mon Jul 10 22:40:11 2006
@@ -1,2 +1,3 @@
01_see
02_usr_bin
+03_lock_config_files_space
Added: trunk/packages/mldonkey/trunk/debian/patches/03_lock_config_files_space.dpatch
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/mldonkey/trunk/debian/patches/03_lock_config_files_space.dpatch?rev=2898&op=file
==============================================================================
--- trunk/packages/mldonkey/trunk/debian/patches/03_lock_config_files_space.dpatch (added)
+++ trunk/packages/mldonkey/trunk/debian/patches/03_lock_config_files_space.dpatch Mon Jul 10 22:40:11 2006
@@ -1,0 +1,221 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 03_lock_config_files_space.dpatch by spiralvoice <spiralvoice at hotmail.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Lock config_files_space.tmp and delete unsed file on startup.
+## DP: Cf. #359237.
+
+ at DPATCH@
+diff -urNad mldonkey-2.7.7~/src/daemon/common/commonOptions.ml mldonkey-2.7.7/src/daemon/common/commonOptions.ml
+--- mldonkey-2.7.7~/src/daemon/common/commonOptions.ml 2006-07-10 22:32:35.000000000 +0000
++++ mldonkey-2.7.7/src/daemon/common/commonOptions.ml 2006-07-10 22:32:41.000000000 +0000
+@@ -35,6 +35,10 @@
+
+ let config_dir_basename = hidden_dir_prefix ^ "mldonkey"
+
++let pid_filename = Printf.sprintf "%s.pid" (Filename.basename Sys.argv.(0))
++
++let security_space_filename = "config_files_space.tmp"
++
+ let home_dir =
+ match Autoconf.system with
+ | "cygwin"
+@@ -107,6 +111,10 @@
+ If you are using a chroot environment, create it inside the chroot.\n"
+ file (if exit then ", exiting..." else "")
+
++let windows_sleep seconds =
++ lprintf_nl "waiting %d seconds to exit..." seconds;
++ Unix.sleep seconds
++
+ let _ =
+ lprintf_nl "Starting MLDonkey %s ... " Autoconf.current_version;
+ let ulof_old = Unix2.c_getdtablesize () in
+@@ -172,62 +180,75 @@
+
+ Unix2.can_write_to_directory (Filename2.temp_directory ());
+
+- if (String2.starts_with (Filename.basename Sys.argv.(0)) "mlnet")
+- then
+- let pid_filename =
+- Printf.sprintf "%s.pid" (Filename.basename Sys.argv.(0)) in
+- let config_space = "config_files_space.tmp" in
+- if Sys.file_exists pid_filename || Sys.file_exists config_space
+- then begin
+- if Sys.file_exists pid_filename then
+- lprintf_nl "PID file %s exists."
+- (Filename.concat file_basedir pid_filename)
+- else
+- if Sys.file_exists config_space then begin
+- lprintf_nl "%s exists." (Filename.concat file_basedir config_space);
+- lprintf "%s" (exit_message config_space);
+- if Autoconf.windows then
+- begin
+- lprintf_nl "waiting 10 seconds to exit...";
+- Unix.sleep 10
+- end;
+- exit 2
+- end;
+- let pid =
+- try
+- Unix2.tryopen_read pid_filename (fun pid_ci ->
+- int_of_string (input_line pid_ci))
+- with _ ->
+- lprintf_nl "But it couldn't be read to check if the process still exists.";
+- lprintf_nl "To avoid doing any harm, MLDonkey will now stop.";
+- exit 2
+- in
+- try
+- Unix.kill pid 0;
+- lprintf "%s" (exit_message pid_filename);
+- exit 2
+- with
+- (* stalled pid file, disregard it *)
+- | Unix.Unix_error (Unix.ESRCH, _, _) ->
+- (lprintf_nl "Removing stalled file %s " pid_filename;
+- try Sys.remove pid_filename with _ -> ())
++ if (String2.starts_with (Filename.basename Sys.argv.(0)) "mlnet") then begin
++ if Sys.file_exists pid_filename then begin
++ lprintf_nl "PID file %s exists." (Filename.concat file_basedir pid_filename);
++ let pid =
++ try
++ Unix2.tryopen_read pid_filename (fun pid_ci ->
++ int_of_string (input_line pid_ci))
++ with _ ->
++ lprintf_nl "But it couldn't be read to check if the process still exists.";
++ lprintf_nl "To avoid doing any harm, MLDonkey will now stop.";
++ if Autoconf.windows then windows_sleep 10;
++ exit 2
++ in
++ try
++ lprintf_nl "Checking whether PID %d is still used..." pid;
++ Unix.kill pid 0;
++ lprintf "%s" (exit_message pid_filename);
++ exit 2
++ with (* stalled pid file, disregard it *)
++ | Unix.Unix_error (Unix.ESRCH, _, _) ->
++ lprintf_nl "Removing stalled file %s..." pid_filename;
++ (try Sys.remove pid_filename with _ -> ())
+ | e ->
+- lprintf "%s" (exit_message pid_filename);
+- if Autoconf.system = "mingw" then lprintf_nl
+- "can not check for stalled pid file because Unix.kill is not implemented on MinGW";
+- lprintf_nl "Exception %s, exiting..." (Printexc2.to_string e);
+- if Autoconf.system = "mingw" then begin
+- lprintf_nl "waiting 10 seconds to exit...";
+- Unix.sleep 10;
+- end;
+- exit 2
+- end;
+-
++ lprintf "%s" (exit_message pid_filename);
++ if Autoconf.system = "mingw" then lprintf_nl
++ "can not check for stalled pid file because Unix.kill is not implemented on MinGW";
++ lprintf_nl "Exception %s, exiting..." (Printexc2.to_string e);
++ if Autoconf.system = "mingw" then windows_sleep 10;
++ exit 2
++ end;
++ if Sys.file_exists security_space_filename then begin
++ try
++ let security_space_oc =
++ Unix.openfile security_space_filename [Unix.O_WRONLY; Unix.O_CREAT] 0o600 in
++ Unix.lockf security_space_oc Unix.F_TLOCK 0;
++ Unix.close security_space_oc;
++ lprintf_nl "Removing stalled file %s..."
++ (Filename.concat file_basedir security_space_filename);
++ begin
++ try
++ (try Unix.close security_space_oc with _ -> ());
++ Sys.remove security_space_filename
++ with e ->
++ lprintf_nl "can not remove %s: %s"
++ (Filename.concat file_basedir security_space_filename)
++ (Printexc2.to_string e);
++ if Autoconf.windows then windows_sleep 10;
++ exit 2
++ end
++ with
++ Unix.Unix_error ((Unix.EAGAIN), _, _) ->
++ lprintf_nl "%s exists and is locked by another process."
++ (Filename.concat file_basedir security_space_filename);
++ lprintf "%s" (exit_message security_space_filename);
++ if Autoconf.windows then windows_sleep 10;
++ exit 2
++ | e ->
++ lprintf_nl "error while checking file %s: %s"
++ (Filename.concat file_basedir security_space_filename)
++ (Printexc2.to_string e);
++ if Autoconf.windows then windows_sleep 10;
++ exit 2
++ end
++ end;
+ let filename =
+- try
++ try
+ Sys.getenv "MLDONKEY_STRINGS"
+ with _ ->
+- "mlnet_strings"
++ "mlnet_strings"
+ in
+ set_strings_file filename
+
+diff -urNad mldonkey-2.7.7~/src/daemon/driver/driverMain.ml mldonkey-2.7.7/src/daemon/driver/driverMain.ml
+--- mldonkey-2.7.7~/src/daemon/driver/driverMain.ml 2006-06-18 20:24:21.000000000 +0000
++++ mldonkey-2.7.7/src/daemon/driver/driverMain.ml 2006-07-10 22:32:41.000000000 +0000
+@@ -561,27 +561,25 @@
+ if !verbose then lprintf_nl (_b "Activated system signal handling")
+
+ let _ =
+- let security_space_filename = "config_files_space.tmp" in
+ begin
+ (* Create a 'config_files_security_space' megabytes file to protect some space
+ for config files at the end. *)
+ try
+- let security_space_fd = Unix32.create_rw security_space_filename in
+- let _ =
++ let security_space_oc = Unix.openfile security_space_filename [Unix.O_WRONLY; Unix.O_CREAT] 0o600 in
+ let len = 32768 in
+- let len64 = Int64.of_int len in
+- let s = String.create len in
++ let s = String.make len ' ' in
+ let pos = ref zero in
+ for i = 1 to !!config_files_security_space do
+ for j = 1 to 32 do (* 32 = 1 MB / 32kB *)
+- Unix32.write security_space_fd !pos s 0 len;
+- pos := !pos ++ len64
++ ignore(Unix2.c_seek64 security_space_oc !pos Unix.SEEK_SET);
++ Unix2.really_write security_space_oc s 0 len;
++ pos := !pos ++ (Int64.of_int len)
+ done
+- done
+- in
+- Unix32.close security_space_fd;
+- with _ ->
+- lprintf_nl (_b "Cannot create Security space file:");
++ done;
++ ignore(Unix2.c_seek64 security_space_oc zero Unix.SEEK_SET);
++ Unix.lockf security_space_oc Unix.F_LOCK (!!config_files_security_space * 1024 * 1024)
++ with e ->
++ lprintf_nl (_b "Cannot create Security space file: %s") (Printexc2.to_string e);
+ lprintf_nl (_b " not enough space on device or bad permissions");
+ lprintf_nl (_b "Exiting...");
+ exit 73;
+@@ -589,9 +587,6 @@
+ Unix32.external_start ();
+
+ (
+- let pid_filename =
+- Printf.sprintf "%s.pid" (Filename.basename Sys.argv.(0))
+- in
+ let pid_file, s =
+ Filename.concat !pid pid_filename,
+ Printf.sprintf "%s\n" (string_of_int(Unix.getpid()))
+@@ -628,7 +623,7 @@
+ DriverGraphics.G.remove_files ();
+ (* In case we have no more space on filesystem for
+ config files, remove the security space file *)
+- Sys.remove security_space_filename;
++ (try Sys.remove security_space_filename with _ -> ());
+ CommonComplexOptions.allow_saving_ini_files := true;
+ DriverInteractive.save_config ();
+ CommonComplexOptions.save_sources ();
Propchange: trunk/packages/mldonkey/trunk/debian/patches/03_lock_config_files_space.dpatch
------------------------------------------------------------------------------
svn:executable = *
More information about the Pkg-ocaml-maint-commits
mailing list