Package: apt-mirror
Version: 0.4.8-3ubuntu1
Tags: patch

--- Please enter the report below this line. ---

wrong create lock file

look http://www.opennet.ru/base/dev/lock_file_ex.txt.html

(http://translate.google.com/translate?hl=en&ie=UTF-8&sl=ru&tl=en&u=http://www.opennet.ru/base/dev/lock_file_ex.txt.html&prev=_t&twu=1)

--- System information. ---
Architecture: i386
Kernel:       Linux 2.6.38-7-generic

Debian Release: squeeze/sid
  500 unstable        debian.seriousdron.ru 
  500 testing         dl.google.com 
  500 stable          dl.google.com 
  500 stable          deb.opera.com 
  500 natty-updates   ru.archive.ubuntu.com 
  500 natty-security  security.ubuntu.com 
  500 natty           ru.archive.ubuntu.com 
  500 natty           ppa.launchpad.net 
  500 natty           extras.ubuntu.com 
  500 natty           archive.canonical.com 
  500 maverick        ppa.launchpad.net 
  500 maverick        archive.canonical.com 
  500 lucid           ppa.launchpad.net 

--- Package information. ---
Depends           (Version) | Installed
===========================-+-===========
adduser                     | 3.112+nmu1ubuntu5
perl-modules                | 5.10.1-17ubuntu4
wget                        | 1.12-2.1ubuntu2
perl                        | 5.10.1-17ubuntu4


Package's Recommends field is empty.

Package's Suggests field is empty.



--- apt-mirror.old	2011-04-09 16:57:09.237888427 +0400
+++ apt-mirror	2011-04-09 17:47:43.001889158 +0400
@@ -178,17 +178,16 @@
 }
 
 sub lock_aptmirror {
-	system ("touch " . get_variable("var_path") . "/apt-mirror.lock");
-}
-
-sub check_lock {
-	if(-e get_variable("var_path") . "/apt-mirror.lock")
+	open (LOCK_FILE, '>', get_variable("var_path") . "/apt-mirror.lock");
+	my $lock = flock(LOCK_FILE, 2 | 4); ## LOCK_EX { 2 }, LOCK_NB { 4 } ## i not know why not work
+	if (!$lock)
 	{
 		die("apt-mirror is already running, exiting");
 	}
 }
 
 sub unlock_aptmirror {
+	close(LOCK_FILE);
 	unlink(get_variable("var_path") . "/apt-mirror.lock");
 }
 
@@ -296,12 +295,6 @@
 #
 #######################################################################################
 
-check_lock();
-
-$SIG{INT} = "unlock_aptmirror";
-$SIG{HUP} = "unlock_aptmirror";
-$SIG{TERM} = "unlock_aptmirror";
-
 lock_aptmirror();
 
 

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to