Diff for /loncom/loncnew between versions 1.28 and 1.29

version 1.28, 2003/10/14 15:36:21 version 1.29, 2003/10/21 14:24:42
Line 45 Line 45
   
 # Change log:  # Change log:
 #    $Log$  #    $Log$
   #    Revision 1.29  2003/10/21 14:24:42  foxr
   #    Fix little typo that may explain growth of connections
   #
 #    Revision 1.28  2003/10/14 15:36:21  albertel  #    Revision 1.28  2003/10/14 15:36:21  albertel
 #    - making it easier to run loncnew,  #    - making it easier to run loncnew,
 #       /etc/init.d/loncontrol startnew  #       /etc/init.d/loncontrol startnew
Line 181  my $MaxConnectionCount = 10; # Will get Line 184  my $MaxConnectionCount = 10; # Will get
 my $ClientConnection = 0; # Uniquifier for client events.  my $ClientConnection = 0; # Uniquifier for client events.
   
 my $DebugLevel = 0;  my $DebugLevel = 0;
 my $NextDebugLevel= 10; # So Sigint can toggle this.  my $NextDebugLevel= 2; # So Sigint can toggle this.
 my $IdleTimeout= 3600; # Wait an hour before pruning connections.  my $IdleTimeout= 3600; # Wait an hour before pruning connections.
   
 #  #
Line 409  sub Tick { Line 412  sub Tick {
  if ($ConnectionRetriesLeft > 0) {   if ($ConnectionRetriesLeft > 0) {
     my $Connections = ($Requests <= $MaxConnectionCount) ?      my $Connections = ($Requests <= $MaxConnectionCount) ?
  $Requests : $MaxConnectionCount;   $Requests : $MaxConnectionCount;
     Debug(1,"Work but no connections, start ".$Connections." of them");      Debug(5,"Work but no connections, start ".$Connections." of them");
     my $successCount = 0;      my $successCount = 0;
     for (my $i =0; $i < $Connections; $i++) {      for (my $i =0; $i < $Connections; $i++) {
  $successCount += MakeLondConnection();   $successCount += MakeLondConnection();
     }      }
     if($successCount == 0) { # All connections failed:      if($successCount == 0) { # All connections failed:
  Debug(1,"Work in queue failed to make any connectiouns\n");   Debug(5,"Work in queue failed to make any connectiouns\n");
  EmptyQueue(); # Fail pending transactions with con_lost.   EmptyQueue(); # Fail pending transactions with con_lost.
     }      }
  } else {   } else {
     ShowStatus(GetServerHost()." >>> DEAD!!! <<<");      ShowStatus(GetServerHost()." >>> DEAD!!! <<<");
     Debug(1,"Work in queue, but gave up on connections..flushing\n");      Debug(5,"Work in queue, but gave up on connections..flushing\n");
     EmptyQueue(); # Connections can't be established.      EmptyQueue(); # Connections can't be established.
  }   }
                 
Line 467  sub ServerToIdle { Line 470  sub ServerToIdle {
     my $Socket   = shift; # Get the socket.      my $Socket   = shift; # Get the socket.
     delete($ActiveTransactions{$Socket}); # Server has no transaction      delete($ActiveTransactions{$Socket}); # Server has no transaction
   
     &Debug(6, "Server to idle");      &Debug(5, "Server to idle");
   
     #  If there's work to do, start the transaction:      #  If there's work to do, start the transaction:
   
     my $reqdata = $WorkQueue->dequeue(); # This is a LondTransaction      my $reqdata = $WorkQueue->dequeue(); # This is a LondTransaction
     unless($reqdata eq undef)  {      if ($reqdata ne undef)  {
  Debug(9, "Queue gave request data: ".$reqdata->getRequest());   Debug(5, "Queue gave request data: ".$reqdata->getRequest());
  &StartRequest($Socket,  $reqdata);   &StartRequest($Socket,  $reqdata);
   
     } else {      } else {
   
     #  There's no work waiting, so push the server to idle list.      #  There's no work waiting, so push the server to idle list.
  &Debug(8, "No new work requests, server connection going idle");   &Debug(5, "No new work requests, server connection going idle");
  $IdleConnections->push($Socket);   $IdleConnections->push($Socket);
     }      }
 }  }
Line 525  sub ClientWritable { Line 528  sub ClientWritable {
  # request.   # request.
   
  &Debug(9,"Send result is ".$result." Defined: ".defined($result));   &Debug(9,"Send result is ".$result." Defined: ".defined($result));
  if(defined($result)) {   if($result ne undef) {
     &Debug(9, "send result was defined");      &Debug(9, "send result was defined");
     if($result == length($Data)) { # Entire string sent.      if($result == length($Data)) { # Entire string sent.
  &Debug(9, "ClientWritable data all written");   &Debug(9, "ClientWritable data all written");
Line 596  The transaction that is being completed. Line 599  The transaction that is being completed.
 =cut  =cut
   
 sub CompleteTransaction {  sub CompleteTransaction {
     &Debug(6,"Complete transaction");      &Debug(5,"Complete transaction");
     my $Socket = shift;      my $Socket = shift;
     my $Transaction = shift;      my $Transaction = shift;
   
Line 635  sub StartClientReply { Line 638  sub StartClientReply {
     &Debug(8," Reply was: ".$data);      &Debug(8," Reply was: ".$data);
     my $Serial         = $ActiveClients{$Client};      my $Serial         = $ActiveClients{$Client};
     my $desc           = sprintf("Connection to lonc client %d",      my $desc           = sprintf("Connection to lonc client %d",
   
  $Serial);   $Serial);
     Event->io(fd       => $Client,      Event->io(fd       => $Client,
       poll     => "w",        poll     => "w",
Line 667  Parameters: Line 669  Parameters:
 sub FailTransaction {  sub FailTransaction {
     my $transaction = shift;      my $transaction = shift;
     Log("WARNING", "Failing transaction ".$transaction->getRequest());      Log("WARNING", "Failing transaction ".$transaction->getRequest());
     Debug(1, "Failing transaction: ".$transaction->getRequest());      Debug(5, "Failing transaction: ".$transaction->getRequest());
     if (!$transaction->isDeferred()) { # If the transaction is deferred we'll get to it.      if (!$transaction->isDeferred()) { # If the transaction is deferred we'll get to it.
  my $client  = $transaction->getClient();   my $client  = $transaction->getClient();
  Debug(1," Replying con_lost to ".$transaction->getRequest());   Debug(5," Replying con_lost to ".$transaction->getRequest());
  StartClientReply($transaction, "con_lost\n");   StartClientReply($transaction, "con_lost\n");
     }      }
     if($ConnectionRetriesLeft <= 0) {      if($ConnectionRetriesLeft <= 0) {
Line 884  sub LondReadable { Line 886  sub LondReadable {
  $ConnectionRetriesLeft = $ConnectionRetries; # success resets the count   $ConnectionRetriesLeft = $ConnectionRetries; # success resets the count
  $Watcher->cancel();   $Watcher->cancel();
  if(exists($ActiveTransactions{$Socket})) {   if(exists($ActiveTransactions{$Socket})) {
     Debug(8,"Completing transaction!!");      Debug(5,"Completing transaction!!");
     CompleteTransaction($Socket,       CompleteTransaction($Socket, 
  $ActiveTransactions{$Socket});   $ActiveTransactions{$Socket});
  } else {   } else {
Line 1246  sub QueueTransaction { Line 1248  sub QueueTransaction {
   
     my $LondSocket    = $IdleConnections->pop();      my $LondSocket    = $IdleConnections->pop();
     if(!defined $LondSocket) { # Need to queue request.      if(!defined $LondSocket) { # Need to queue request.
  Debug(8,"Must queue...");   Debug(5,"Must queue...");
  $WorkQueue->enqueue($requestData);   $WorkQueue->enqueue($requestData);
  if($ConnectionCount < $MaxConnectionCount) {   if($ConnectionCount < $MaxConnectionCount) {
     if($ConnectionRetriesLeft > 0) {      if($ConnectionRetriesLeft > 0) {
  Debug(4,"Starting additional lond connection");   Debug(5,"Starting additional lond connection");
  if(MakeLondConnection() == 0) {   if(MakeLondConnection() == 0) {
     EmptyQueue(); # Fail transactions, can't make connection.      EmptyQueue(); # Fail transactions, can't make connection.
  }   }
Line 1288  sub ClientRequest { Line 1290  sub ClientRequest {
     my $rv = $socket->recv($thisread, POSIX::BUFSIZ, 0);      my $rv = $socket->recv($thisread, POSIX::BUFSIZ, 0);
     Debug(8, "rcv:  data length = ".length($thisread)      Debug(8, "rcv:  data length = ".length($thisread)
   ." read =".$thisread);    ." read =".$thisread);
     unless (defined $rv && length($thisread)) {      unless (defined $rv  && length($thisread)) {
  # Likely eof on socket.   # Likely eof on socket.
  Debug(5,"Client Socket closed on lonc for ".$RemoteHost);   Debug(5,"Client Socket closed on lonc for ".$RemoteHost);
  close($socket);   close($socket);

Removed from v.1.28  
changed lines
  Added in v.1.29


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