Diff for /loncom/lonsql between versions 1.26 and 1.33

version 1.26, 2001/03/27 19:57:53 version 1.33, 2001/04/16 18:36:22
Line 23  sub wanted { Line 23  sub wanted {
     push(@metalist,"$dir/$_");      push(@metalist,"$dir/$_");
 }  }
   
   
 $childmaxattempts=10;  $childmaxattempts=10;
 $run =0;#running counter to generate the query-id  $run =0;#running counter to generate the query-id
   
Line 39  while ($configline=<CONFIG>) { Line 38  while ($configline=<CONFIG>) {
 }  }
 close(CONFIG);  close(CONFIG);
   
   # ------------------------------------- Make sure that database can be accessed
   {
       my $dbh;
       unless (
       $dbh = DBI->connect("DBI:mysql:loncapa","www",$perlvar{'lonSqlAccess'},{ RaiseError =>0,PrintError=>0})
       ) { 
    print "Cannot connect to database!\n";
    exit;
       }
       else {
    $dbh->disconnect;
       }
   }
   
 # --------------------------------------------- Check if other instance running  # --------------------------------------------- Check if other instance running
   
 my $pidfile="$perlvar{'lonDaemons'}/logs/lonsql.pid";  my $pidfile="$perlvar{'lonDaemons'}/logs/lonsql.pid";
Line 60  while ($configline=<CONFIG>) { Line 73  while ($configline=<CONFIG>) {
     chomp($ip);      chomp($ip);
   
     $hostip{$ip}=$id;      $hostip{$ip}=$id;
   
     if ($id eq $perlvar{'lonHostID'}) { $thisserver=$name; }      if ($id eq $perlvar{'lonHostID'}) { $thisserver=$name; }
   
     $PREFORK++;      $PREFORK++;
Line 191  sub make_new_child { Line 203  sub make_new_child {
         #open database handle          #open database handle
  # making dbh global to avoid garbage collector   # making dbh global to avoid garbage collector
  unless (   unless (
  $dbh = DBI->connect("DBI:mysql:loncapa","www","123",{ RaiseError =>0,PrintError=>0})   $dbh = DBI->connect("DBI:mysql:loncapa","www",$perlvar{'lonSqlAccess'},{ RaiseError =>0,PrintError=>0})
  ) {    ) { 
             my $st=120+int(rand(240));               sleep(10+int(rand(20)));
     &logthis("<font color=blue>WARNING: Couldn't connect to database  ($st secs): $@</font>");      &logthis("<font color=blue>WARNING: Couldn't connect to database  ($st secs): $@</font>");
     print "database handle error\n";      print "database handle error\n";
     sleep($st);  
     exit;      exit;
   
   };    };
Line 251  sub make_new_child { Line 262  sub make_new_child {
  }   }
     }      }
     # do custom metadata searching here and build into result      # do custom metadata searching here and build into result
     if ($custom) {      if ($custom or $customshow) {
  &logthis("am going to do custom query for $custom");   &logthis("am going to do custom query for $custom");
  if ($query) {   if ($query) {
     @metalist=map {$perlvar{'lonDocRoot'}.$_.'.meta'} @files;      @metalist=map {$perlvar{'lonDocRoot'}.$_.'.meta'} @files;
Line 284  sub make_new_child { Line 295  sub make_new_child {
  $m2=~s/\.meta$//;   $m2=~s/\.meta$//;
  unless ($query) {   unless ($query) {
     my $q2="select * from metadata where url like '$m2'";      my $q2="select * from metadata where url like '$m2'";
     my $sth = $dbh->prepare($query);      my $sth = $dbh->prepare($q2);
     $sth->execute();      $sth->execute();
     my $r1=$sth->fetchall_arrayref;      my $r1=$sth->fetchall_arrayref;
     map {my $a=$_;       map {my $a=$_; 
Line 352  sub reply { Line 363  sub reply {
     }      }
   } else {    } else {
     $answer='self_reply';      $answer='self_reply';
       $answer=subreply($cmd,$server);
   }     } 
   return $answer;    return $answer;
 }  }

Removed from v.1.26  
changed lines
  Added in v.1.33


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>