Diff for /loncom/loncnew between versions 1.96 and 1.97

version 1.96, 2011/01/25 11:02:35 version 1.97, 2011/06/16 07:18:53
Line 26 Line 26
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 #  #
 # new lonc handles n request out bver m connections to londs.  # new lonc handles n request out over m connections to londs.
 # This module is based on the Event class.  # This module is based on the Event class.
 #   Development iterations:  #   Development iterations:
 #    - Setup basic event loop.   (done)  #    - Setup basic event loop.   (done)
Line 349  sub child_exit { Line 349  sub child_exit {
   
 =head2 Tick  =head2 Tick
   
 Invoked  each timer tick.  Invoked each timer tick.
   
 =cut  =cut
   
Line 488  sub ServerToIdle { Line 488  sub ServerToIdle {
   
 Event callback for when a client socket is writable.  Event callback for when a client socket is writable.
   
 This callback is established when a transaction reponse is  This callback is established when a transaction response is
 avaiable from lond.  The response is forwarded to the unix socket  available from lond.  The response is forwarded to the unix socket
 as it becomes writable in this sub.  as it becomes writable in this sub.
   
 Parameters:  Parameters:
Line 589  Parameters: Line 589  Parameters:
   
 =item Socket  =item Socket
   
 Socket on which the lond transaction occured.  This is a  Socket on which the lond transaction occurred.  This is a
 LondConnection. The data received is in the TransactionReply member.  LondConnection. The data received are in the TransactionReply member.
   
 =item Transaction  =item Transaction
   
Line 630  sub CompleteTransaction { Line 630  sub CompleteTransaction {
   
 =item data  =item data
   
     The data to send to apached client.      The data to send to apache client.
   
 =cut  =cut
   
Line 743  Parameters: Line 743  Parameters:
   
 =item Restart  =item Restart
   
 nonzero if we are allowed to create a new connection.  non-zero if we are allowed to create a new connection.
   
 =cut  =cut
   
Line 787  is readable.  The action is state depend Line 787  is readable.  The action is state depend
   
 =head3 State=Initialized  =head3 State=Initialized
   
 We''re waiting for the challenge, this is a no-op until the  We're waiting for the challenge, this is a no-op until the
 state changes.  state changes.
   
 =head3 State=Challenged   =head3 State=Challenged 
Line 797  The connection must echo the challenge b Line 797  The connection must echo the challenge b
   
 =head3 State=ChallengeReplied  =head3 State=ChallengeReplied
   
 The challenge has been replied to.  The we are receiveing the   The challenge has been replied to.  Then we are receiving the 
 'ok' from the partner.  'ok' from the partner.
   
 =head3  State=ReadingVersionString  =head3  State=ReadingVersionString
Line 823  The the key has been requested, now we a Line 823  The the key has been requested, now we a
 =head3 State=Idle   =head3 State=Idle 
   
 The encryption key has been negotiated or we have finished   The encryption key has been negotiated or we have finished 
 reading data from the a transaction.   If the callback data has  reading data from the a transaction.   If the callback data have
 a client as well as the socket iformation, then we are   a client as well as the socket nformation, then we are 
 doing a transaction and the data received is relayed to the client  doing a transaction and the data received are relayed to the client
 before the socket is put on the idle list.  before the socket is put on the idle list.
   
 =head3 State=SendingRequest  =head3 State=SendingRequest
Line 842  to readable to receive the reply. Line 842  to readable to receive the reply.
 The parameter to this function are:  The parameter to this function are:
   
 The event. Implicit in this is the watcher and its data.  The data   The event. Implicit in this is the watcher and its data.  The data 
 contains at least the lond connection object and, if a   contain at least the lond connection object and, if a 
 transaction is in progress, the socket attached to the local client.  transaction is in progress, the socket attached to the local client.
   
 =cut  =cut
Line 985  event.  The action taken is very state d Line 985  event.  The action taken is very state d
 =head3 State = Connected   =head3 State = Connected 
   
 The connection is in the process of sending the 'init' hailing to the  The connection is in the process of sending the 'init' hailing to the
 lond on the remote end.  The connection object''s Writable member is  lond on the remote end.  The connection object's Writable member is
 called.  On error, ConnectionError is called to destroy the connection  called.  On error, ConnectionError is called to destroy the connection
 and remove it from the ActiveConnections hash  and remove it from the ActiveConnections hash
   
Line 1196  sub QueueDelayed { Line 1196  sub QueueDelayed {
 =head2 MakeLondConnection  =head2 MakeLondConnection
   
 Create a new lond connection object, and start it towards its initial  Create a new lond connection object, and start it towards its initial
 idleness.  Once idle, it becomes elligible to receive transactions  idleness.  Once idle, it becomes eligible to receive transactions
 from the work queue.  If the work queue is not empty when the  from the work queue.  If the work queue is not empty when the
 connection is completed and becomes idle, it will dequeue an entry and  connection is completed and becomes idle, it will dequeue an entry and
 start off on it.  start off on it.
Line 1247  sub MakeLondConnection { Line 1247  sub MakeLondConnection {
  if($ConnectionCount == 1) { # First Connection:   if($ConnectionCount == 1) { # First Connection:
     QueueDelayed;      QueueDelayed;
  }   }
  Log("SUCESS", "Created connection ".$ConnectionCount   Log("SUCCESS", "Created connection ".$ConnectionCount
     ." to host ".GetServerHost());      ." to host ".GetServerHost());
  return 1; # Return success.   return 1; # Return success.
     }      }
Line 1268  reply. Line 1268  reply.
   
 =item $Client  =item $Client
   
 Connection to the client that is making this request We got the  Connection to the client that is making this request. We got the
 request from this socket, and when the request has been relayed to  request from this socket, and when the request has been relayed to
 lond and we get a reply back from lond it will get sent to this  lond and we get a reply back from lond it will get sent to this
 socket.  socket.
Line 1358  sub QueueTransaction { Line 1358  sub QueueTransaction {
 =pod  =pod
   
 =head2 ClientRequest  =head2 ClientRequest
   
 Callback that is called when data can be read from the UNIX domain  Callback that is called when data can be read from the UNIX domain
 socket connecting us with an apache server process.  socket connecting us with an apache server process.
   
Line 1457  sub accept_client { Line 1458  sub accept_client {
 Callback that is called when a connection is received on the unix  Callback that is called when a connection is received on the unix
 socket for a new client of lonc.  The callback is parameterized by the  socket for a new client of lonc.  The callback is parameterized by the
 event.. which is a-priori assumed to be an io event, and therefore has  event.. which is a-priori assumed to be an io event, and therefore has
 an fd member that is the Listener socket.  We Accept the connection  an fd member that is the Listener socket.  We accept the connection
 and register a new event on the readability of that socket:  and register a new event on the readability of that socket:
   
 =cut  =cut
Line 1537  sub GetServerPort { Line 1538  sub GetServerPort {
 Setup a lonc listener event.  The event is called when the socket  Setup a lonc listener event.  The event is called when the socket
 becomes readable.. that corresponds to the receipt of a new  becomes readable.. that corresponds to the receipt of a new
 connection.  The event handler established will accept the connection  connection.  The event handler established will accept the connection
 (creating a communcations channel), that int turn will establish  (creating a communcations channel), that in turn will establish
 another event handler to subess requests.  another event handler to subess requests.
   
 =head2  Parameters:  =head2  Parameters:
Line 1677  sub ToggleDebug { Line 1678  sub ToggleDebug {
   
 This sub implements a child process for a single lonc daemon.  This sub implements a child process for a single lonc daemon.
 Optional parameter:  Optional parameter:
    $socket  - if provided, this is a socket already open for listen     $socket  - if provided, this is a socket already open for listening
               on the client socket. Otherwise, a new listen is set up.                on the client socket. Otherwise, a new listener is set up.
   
 =cut  =cut
   
Line 2078  die "Main Event loop exited: $ret"; Line 2079  die "Main Event loop exited: $ret";
 =head1 CheckKids  =head1 CheckKids
   
   Since kids do not die as easily in this implementation    Since kids do not die as easily in this implementation
 as the previous one, there  is no need to restart the  as the previous one, there is no need to restart the
 dead ones (all dead kids get restarted when they die!!)  dead ones (all dead kids get restarted when they die!!)
 The only thing this function does is to pass USR1 to the  The only thing this function does is to pass USR1 to the
 kids so that they report their status.  kids so that they report their status.
Line 2148  sub UpdateKids { Line 2149  sub UpdateKids {
 =head1 Restart  =head1 Restart
   
 Signal handler for HUP... all children are killed and  Signal handler for HUP... all children are killed and
 we self restart.  This is an el-cheapo way to re read  we self restart.  This is an el-cheapo way to re-read
 the config file.  the config file.
   
 =cut  =cut
Line 2294  If there are pending transactions in the Line 2295  If there are pending transactions in the
 they are failed (saved if critical).  If the connection  they are failed (saved if critical).  If the connection
 retry count gets exceeded by this, the  retry count gets exceeded by this, the
 remote host is marked as dead.  remote host is marked as dead.
 Called when timeouts occured during the connection and  Called when timeouts occurred during the connection and
 connection dialog with a remote host.  connection dialog with a remote host.
   
 =item Critical Host makred DEAD <hostname>     =item Critical Host makred DEAD <hostname>   
Line 2421  the event processing loop is entered. Line 2422  the event processing loop is entered.
 =item INFO Updating connections via SIGUSR2  =item INFO Updating connections via SIGUSR2
                                                                           
 SIGUSR2 received. The original code would kill all clients, re-read the host file,  SIGUSR2 received. The original code would kill all clients, re-read the host file,
 then restart children for each host.  Now that childrean aree started on demand, this  then restart children for each host.  Now that children are started on demand, this
 just kills all child processes and lets requests start them as needed again.  just kills all child processes and lets requests start them as needed again.
   
   
Line 2432  SigHUP received.  all the children are k Line 2433  SigHUP received.  all the children are k
 =item CRITICAL Nicely killing lonc for host pid = <pid>  =item CRITICAL Nicely killing lonc for host pid = <pid>
   
 Attempting to kill the child that is serving the specified host (pid given) cleanly via  Attempting to kill the child that is serving the specified host (pid given) cleanly via
 SIGQUIT  The child should handle that, clean up nicely and exit.  SIGQUIT.  The child should handle that, clean up nicely and exit.
   
 =item CRITICAL Nastily killing lonc for host pid = <pid>  =item CRITICAL Nastily killing lonc for host pid = <pid>
   

Removed from v.1.96  
changed lines
  Added in v.1.97


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