Permalink
Browse files

* Allow Interchange to install and run on a threaded system without

  manual installation.

    1. Query on installation with a threaded Perl. If you answer
    "yes" it will create the file _allow_threads and then build
    and test.

    2. Added an os hint that inserts the MV_GETPPID_BROKEN
    fix if on Linux and running threads.

    3. Once you have installed with threads, and the _allow_threads
    file is in the IC root, you don't need to set the environment
    variable anymore. You will get a warning.

    4. Put in a check for Perl 5.8.5 to be allowed to run with
    threads. There were several ithreads bugs fixed in that version.
  • Loading branch information...
1 parent 6380ff4 commit d8cf3398c5db2d3ad42aa3ea63e804fa6bfabdf2 @perusionmike perusionmike committed Feb 27, 2005
Showing with 114 additions and 13 deletions.
  1. +35 −5 Makefile.PL
  2. +24 −0 hints.pl
  3. +44 −8 scripts/interchange.PL
  4. +11 −0 test.pl
View
@@ -59,10 +59,6 @@ unless($@) {
$ENV{PERL_RL} = 'Perl';
}
-if(! $ENV{MINIVEND_FORCE_THREADS} and $Config{usethreads} || $Config{useithreads} || $Config{use5005threads}) {
- die "Interchange will not work with a thread-enabled perl.\n";
-}
-
my $term;
if($TermRead) {
eval {
@@ -360,6 +356,29 @@ sub initialize {
close UID;
}
+ $Global::TryingThreads = $Config{usethreads}
+ || $Config{useithreads}
+ || $Config{use5005threads};
+
+ if($Global::TryingThreads and ! -f '_allow_threads') {
+ print <<EOF;
+It is not recommended that you run Interchange with a thread-enabled perl,
+which you have called this installer with. Either rerun with
+
+ /path/to/non-threaded/perl Makefile.PL
+
+or accept the possible problems that come with running on an experimental
+software system.
+EOF
+
+ my $ans = my_prompt("Do you want to try running with threads? ", 'n');
+ exit if $ans !~ /^\s*y/i;
+ open(THR, ">_allow_threads")
+ or die "Can't write allow threads file: $!\n";
+ print THR "I agree not to hold anyone but myself responsible for the results of running an experimental system.\n";
+ close THR;
+ }
+
#warn "Got past open UID file , uid=$uid user=$>\n";
GETUID: {
@@ -583,12 +602,23 @@ EOF
"$realdir/$_";
}
}
+
+ ALLOWTHREADS: {
+ unlink "$realdir/_allow_threads";
+ last ALLOWTHREADS unless $Global::TryingThreads;
+ open(THR, ">$realdir/_allow_threads")
+ or die "Can't write allow threads file: $!\n";
+ print THR "I agree not to hold anyone but myself responsible for the results of running an experimental system.\n";
+ close THR;
+ }
+
if($MV::Default{LSB}) {
my $d = cwd();
print "Doing LSB install...\n";
do './install_lsb.pl';
print "Done with LSB install.\n";
}
+
if(@remove_old) {
if($MV::Default{UNLINK}) {
print "Removing old files....";
@@ -860,7 +890,7 @@ WriteMakefile(
NAME => "Interchange",
DISTNAME => "interchange",
clean => {
- FILES => "lib/IniConf.pm _uid _db_storable _session_storable lib/File/CounterFile.pm scripts/initp.pl scripts/compile_link scripts/config_prog scripts/configdump scripts/dump scripts/expire scripts/localize scripts/expireall scripts/makecat scripts/ic_mod_perl scripts/interchange scripts/offline scripts/restart scripts/update",
+ FILES => "lib/IniConf.pm _uid _db_storable _allow_threads _session_storable lib/File/CounterFile.pm scripts/initp.pl scripts/compile_link scripts/config_prog scripts/configdump scripts/dump scripts/expire scripts/localize scripts/expireall scripts/makecat scripts/ic_mod_perl scripts/interchange scripts/offline scripts/restart scripts/update",
},
dist => {
View
@@ -32,6 +32,30 @@ sub get_hints {
};
push @out, [ $condition, $routine ];
+ $condition = sub { $Global::TryingThreads && $^O =~ /linux/i };
+ $routine = sub {
+ my $fn = 'interchange.cfg.dist';
+ rename $fn, "$fn.bak";
+ open HINTIN, "$fn.bak"
+ or die "cannot open $fn.bak: $!\n";
+ open HINTOUT, ">$fn"
+ or die "cannot write $fn: $!\n";
+ while(<HINTIN>) {
+ print HINTOUT $_;
+ }
+ print HINTOUT <<EOF;
+
+## Added because threaded Perl on linux has broken getppid() as
+## of this distribution
+Variable MV_GETPPID_BROKEN 1
+EOF
+ close HINTIN;
+ close HINTOUT;
+ unlink "$fn.bak";
+ return 1;
+ };
+ push @out, [ $condition, $routine ];
+
return @out;
}
View
@@ -3,7 +3,7 @@
#
# Interchange version 5.3.1
#
-# $Id: interchange.PL,v 2.82 2005-01-24 22:08:14 jon Exp $
+# $Id: interchange.PL,v 2.83 2005-02-27 08:29:17 mheins Exp $
#
# Copyright (C) 2002-2005 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -38,13 +38,6 @@ use strict;
use Config;
-BEGIN {
- if(! $ENV{MINIVEND_FORCE_THREADS}
- && ($Config{usethreads} || $Config{useithreads} || $Config{use5005threads})) {
- die "Interchange will not work with a thread-enabled perl.\n";
- }
-}
-
## Comment this back in when we remove support for Perl 5.6.0
#no Config;
@@ -64,6 +57,16 @@ BEGIN {
$Global::VendRoot = $Global::VendRoot || '/usr/local/interchange';
# $Global::VendRoot = $Global::VendRoot || '~_~INSTALLARCHLIB~_~';
+ -f "$Global::VendRoot/_allow_threads" and $ENV{MINIVEND_FORCE_THREADS} = 1;
+
+ if( ($Config{usethreads} || $Config{useithreads} || $Config{use5005threads}) ) {
+ $Global::TryingThreads = 1;
+ }
+
+ if( $Global::TryingThreads and ! $ENV{MINIVEND_FORCE_THREADS} ) {
+ die "Interchange will not work with a thread-enabled perl.\n";
+ }
+
if(-f "$Global::VendRoot/interchange.cfg") {
$Global::ExeName = 'interchange';
$Global::ConfigFile = 'interchange.cfg';
@@ -849,6 +852,39 @@ EOF
}
}
+ THREADCHECK: {
+ last THREADCHECK unless $Global::TryingThreads;
+ my $high_enough;
+ eval {
+ require 5.8.5;
+ $high_enough = 1;
+ };
+
+ unless($high_enough) {
+ die "Your Perl version is not high enough to run threads, needs 5.8.5.\n";
+ }
+
+ my $msg = <<EOF;
+***************************************************************
+***************************************************************
+**** ****
+**** You are running a Perl with threads enabled -- this ****
+**** is not recommended for a production environment. ****
+**** ****
+**** If the Interchange daemon does not start, add this ****
+**** line to interchange.cfg: ****
+**** ****
+**** Variable MV_GETPPID_BROKEN 1 ****
+**** ****
+**** Then restart the server. ****
+**** ****
+***************************************************************
+***************************************************************
+EOF
+ chomp $msg;
+ logGlobal($msg);
+ }
+
# The global configuration set up which catalogs exist.
# Certain ones may have been skipped with -skip on command line...
CATCONFIG: {
View
11 test.pl
@@ -16,6 +16,16 @@
$ENV{MINIVEND_ROOT} = "$cur_dir/blib";
$ENV{MINIVEND_PORT} = 8786 unless defined $ENV{MINIVEND_PORT};
+my $extra_cfg = '';
+
+if(-f '_allow_threads') {
+ open(THR, ">$ENV{MINIVEND_ROOT}/_allow_threads")
+ or die "Can't write allow threads file: $!\n";
+ print THR "I agree not to hold anyone but myself responsible for the results of running an experimental system.\n";
+ close THR;
+ $^O =~ /linux/i and $extra_cfg = 'Variable MV_GETPPID_BROKEN 1';
+}
+
open(CONFIG, ">$ENV{MINIVEND_ROOT}/interchange.cfg")
or die "open: $!\n";
@@ -24,6 +34,7 @@
TcpMap $ENV{MINIVEND_PORT} -
TagDir 0
TagDir etc
+$extra_cfg
EOF
open(CONFIG, ">$ENV{MINIVEND_ROOT}/catalog.cfg")

0 comments on commit d8cf339

Please sign in to comment.