bug-automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: maintainer mode parallel make issue


From: Ralf Wildenhues
Subject: Re: maintainer mode parallel make issue
Date: Thu, 16 Apr 2009 21:46:15 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

* Eric Blake wrote on Thu, Apr 16, 2009 at 09:31:29PM CEST:
> At any rate, I'll repeat this information to the cygwin developers, along 
> with 
> any ideas we have of how to trim it into a smaller testcase implicating just 
> XFile::lock.

You can try this; test against git next of Automake.
However, it also causes a hang on Cygwin, so there may be an independent
bug (in the test or in perl); the lock() called from the thread seems to
never complete.

Cheers,
Ralf

    Test XFile::lock semantics.
    
    * lib/Automake/tests/Lock.pl: New test.
    * lib/Automake/tests/Makefile.am: Adjust.
    Report by Eric Blake.

diff --git a/lib/Automake/tests/Lock.pl b/lib/Automake/tests/Lock.pl
new file mode 100644
index 0000000..0c85420
--- /dev/null
+++ b/lib/Automake/tests/Lock.pl
@@ -0,0 +1,60 @@
+# Copyright (C) 2009  Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GNU Automake is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+BEGIN {
+  use Config;
+  if (eval { require 5.007_002; }      # for CLONE support
+      && $Config{useithreads})
+    {
+      require threads;
+      import threads;
+      require threads::shared;
+      import threads::shared;
+    }
+  else
+    {
+      exit 77;
+    }
+}
+
+use Automake::XFile;
+
+my $failed = 0;
+my $done : shared = 0;
+my $filename = "lockfile";
+
+my $file = new Automake::XFile $filename, O_RDWR|O_CREAT;
+$file->lock (LOCK_EX);
+
+my $thread = threads->new (sub {
+    my $file2 = new Automake::XFile $filename, O_RDWR|O_CREAT;
+    $file2->lock (LOCK_EX);
+    $done = 1;
+    $file2->close;
+    return 0;
+});
+
+threads->yield; # Give the thread some time to run
+sleep 1;        # and some more, just in case.
+$failed = 1 if $done == 1;
+$failed = 1 if $file->lock (LOCK_UN);
+$failed = 1 if $thread->join;
+$failed = 1 if $done != 1;
+$failed = 1 if $file->close;
+$failed = 1 if unlink ($filename) != 1;
+
+exit ($failed);
diff --git a/lib/Automake/tests/Makefile.am b/lib/Automake/tests/Makefile.am
index b56f3dc..fbebd5f 100644
--- a/lib/Automake/tests/Makefile.am
+++ b/lib/Automake/tests/Makefile.am
@@ -24,6 +24,7 @@ Condition.pl \
 Condition-t.pl \
 DisjConditions.pl \
 DisjConditions-t.pl \
+Lock.pl \
 Version.pl \
 Wrap.pl
 




reply via email to

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