[LON-CAPA-cvs] cvs: loncom / loncnew

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 18 Apr 2003 03:10:36 -0000


This is a MIME encoded message

--albertel1050635436
Content-Type: text/plain

albertel		Thu Apr 17 23:10:36 2003 EDT

  Modified files:              
    /loncom	loncnew 
  Log:
  - correcting pod documentation so that 'perldoc loncnew' runs and generates something that looks reasonable
  
  
--albertel1050635436
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20030417231036.txt"

Index: loncom/loncnew
diff -u loncom/loncnew:1.2 loncom/loncnew:1.3
--- loncom/loncnew:1.2	Thu Apr 17 22:59:31 2003
+++ loncom/loncnew	Thu Apr 17 23:10:36 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network with CAPA
 # lonc maintains the connections to remote computers
 #
-# $Id: loncnew,v 1.2 2003/04/18 02:59:31 albertel Exp $
+# $Id: loncnew,v 1.3 2003/04/18 03:10:36 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -103,10 +103,13 @@
 
 
 #
+
 =pod
-=head 2 GetPeerName
-   Returns the name of the host that a socket object is connected
-   to.
+
+=head2 GetPeerName
+
+Returns the name of the host that a socket object is connected to.
+
 =cut
 
 sub GetPeername {
@@ -127,9 +130,13 @@
 }
 #----------------------------- Timer management ------------------------
 =pod
+
 =head2 Debug
-   Invoked to issue a debug message.
+
+Invoked to issue a debug message.
+
 =cut
+
 sub Debug {
     my $level   = shift;
     my $message = shift;
@@ -145,9 +152,13 @@
 	$socket->Dump();
     }
 }
+
 =pod
+
 =head2 Tick
-    Invoked  each timer tick.
+
+Invoked  each timer tick.
+
 =cut
 
 sub Tick {
@@ -160,12 +171,18 @@
 }
 
 =pod
+
 =head2 SetupTimer
-   Sets up a 1 per sec recurring timer event.  The event handler is used to:
 
-=item Trigger timeouts on communications along active sockets.
-=item Trigger disconnections of idle sockets.
+Sets up a 1 per sec recurring timer event.  The event handler is used to:
 
+=item
+
+Trigger timeouts on communications along active sockets.
+
+=item
+
+Trigger disconnections of idle sockets.
 
 =cut
 
@@ -173,18 +190,22 @@
     Debug(6, "SetupTimer");
     Event->timer(interval => 1, debug => 1, cb => \&Tick );
 }
+
 =pod
+
 =head2 ServerToIdle
-   This function is called when a connection to the server is
-ready for more work. 
-   If there is work in the Work queue the top element is dequeued
+
+This function is called when a connection to the server is
+ready for more work.
+
+If there is work in the Work queue the top element is dequeued
 and the connection will start to work on it.  If the work queue is
 empty, the connection is pushed on the idle connection stack where
 it will either get another work unit, or alternatively, if it sits there
 long enough, it will be shut down and released.
 
-
 =cut
+
 sub ServerToIdle {
     my $Socket   = shift;	# Get the socket.
 
@@ -208,18 +229,26 @@
 	$IdleConnections->push($Socket);
     }
 }
+
 =pod
+
 =head2 ClientWritable
-  Event callback for when a client socket is writable.
-  This callback is established when a transaction reponse is
-  avaiable from lond.  The response is forwarded to the unix socket
-  as it becomes writable in this sub.
+
+Event callback for when a client socket is writable.
+
+This callback is established when a transaction reponse is
+avaiable from lond.  The response is forwarded to the unix socket
+as it becomes writable in this sub.
+
 Parameters:
 
-=item Event - The event that has been triggered. Event->w->data is
-              the data and Event->w->fd is the socket to write.
+=item Event
+
+The event that has been triggered. Event->w->data is
+the data and Event->w->fd is the socket to write.
 
 =cut
+
 sub ClientWritable {
     my $Event    = shift;
     my $Watcher  = $Event->w;
@@ -280,19 +309,28 @@
 }
 
 =pod
+
 =head2 CompleteTransaction
-  Called when the reply data has been received for a lond 
+
+Called when the reply data has been received for a lond 
 transaction.   The reply data must now be sent to the
 ultimate client on the other end of the Unix socket.  This is
 done by setting up a writable event for the socket with the
 data the reply data.
+
 Parameters:
-=item Socket - Socket on which the lond transaction occured.  This
-      is a LondConnection. The data received is in the 
-	TransactionReply member.
-=item Client - Unix domain socket open on the ultimate client.
+
+=item Socket
+
+Socket on which the lond transaction occured.  This is a
+LondConnection. The data received is in the TransactionReply member.
+
+=item Client
+
+Unix domain socket open on the ultimate client.
 
 =cut
+
 sub CompleteTransaction {
     &Debug(6,"Complete transaction");
     my $Socket = shift;
@@ -313,45 +351,63 @@
 
 
 =pod
+
 =head2 LondReadable
+
 This function is called whenever a lond connection
 is readable.  The action is state dependent:
 
-=head3 State = Initialized
-    We''re waiting for the challenge, this is a no-op until the
+=head3 State=Initialized
+
+We''re waiting for the challenge, this is a no-op until the
 state changes.
+
 =head3 State=Challenged 
-    The challenge has arrived we need to transition to Writable.
+
+The challenge has arrived we need to transition to Writable.
 The connection must echo the challenge back.
+
 =head3 State=ChallengeReplied
-    The challenge has been replied to.  The we are receiveing the 
+
+The challenge has been replied to.  The we are receiveing the 
 'ok' from the partner.
+
 =head3 State=RequestingKey
-    The ok has been received and we need to send the request for
+
+The ok has been received and we need to send the request for
 an encryption key.  Transition to writable for that.
+
 =head3 State=ReceivingKey
-    The the key has been requested, now we are reading the new key.
+
+The the key has been requested, now we are reading the new key.
+
 =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
 a client as well as the socket iformation, then we are 
 doing a transaction and the data received is relayed to the client
 before the socket is put on the idle list.
+
 =head3 State=SendingRequest
-    I do not think this state can be received here, but if it is,
+
+I do not think this state can be received here, but if it is,
 the appropriate thing to do is to transition to writable, and send
 the request.
+
 =head3 State=ReceivingReply
-    We finished sending the request to the server and now transition
+
+We finished sending the request to the server and now transition
 to readable to receive the reply. 
 
 The parameter to this function are:
+
 The event. Implicit in this is the watcher and its data.  The data 
 contains at least the lond connection object and, if a 
 transaction is in progress, the socket attached to the local client.
 
-
 =cut
+
 sub LondReadable {
     my $Event      = shift;
     my $Watcher    = $Event->w;
@@ -422,49 +478,60 @@
 	Debug(4, "Invalid state in LondReadable");
     }
 }
+
 =pod
+
 =head2 LondWritable
+
 This function is called whenever a lond connection
 becomes writable while there is a writeable monitoring
 event.  The action taken is very state dependent:
+
 =head3 State = Connected 
-  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 called.
-   On error, ConnectionError is called to destroy
-   the connection and remove it from the ActiveConnections
-   hash
+
+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
+called.  On error, ConnectionError is called to destroy the connection
+and remove it from the ActiveConnections hash
+
 =head3 Initialized
-   'init' has been sent, writability monitoring is 
-    removed and readability monitoring is started
-    with LondReadable as the callback.
+
+'init' has been sent, writability monitoring is removed and
+readability monitoring is started with LondReadable as the callback.
+
 =head3 ChallengeReceived
-    The connection has received the who are you 
-   challenge from the remote system, and is in the
-    process of sending the challenge response. 
-    Writable is called.
+
+The connection has received the who are you challenge from the remote
+system, and is in the process of sending the challenge
+response. Writable is called.
+
 =head3 ChallengeReplied
-    The connection has replied to the initial challenge
-    The we switch to monitoring readability looking
-    for the server to reply with 'ok'.
+
+The connection has replied to the initial challenge The we switch to
+monitoring readability looking for the server to reply with 'ok'.
+
 =head3 RequestingKey
-    The connection is in the process of requesting its
-    encryption key.  Writable is called.
+
+The connection is in the process of requesting its encryption key.
+Writable is called.
+
 =head3 ReceivingKey
-    The connection has sent the request for a key.
-    Switch to readability monitoring to accept the key
+
+The connection has sent the request for a key.  Switch to readability
+monitoring to accept the key
+
 =head3 SendingRequest
-    The connection is in the process of sending a
-    request to the server.  This request is part of
-    a client transaction.  All the states until now
-    represent the client setup protocol. Writable
-    is called.
+
+The connection is in the process of sending a request to the server.
+This request is part of a client transaction.  All the states until
+now represent the client setup protocol. Writable is called.
+
 =head3 ReceivingReply
-    The connection has sent a request.  Now it must
-    receive a reply.  Readability monitoring is
-    requested.
 
- This function is an event handler and therefore receives as
+The connection has sent a request.  Now it must receive a reply.
+Readability monitoring is requested.
+
+This function is an event handler and therefore receives as
 a parameter the event that has fired.  The data for the watcher
 of this event is a reference to a list of one or two elements,
 depending on state. The first (and possibly only) element is the
@@ -472,6 +539,7 @@
 is the socket on which to return a reply to the caller.
 
 =cut
+
 sub LondWritable {
     my $Event   = shift;
     my $Watcher = $Event->w;
@@ -564,13 +632,17 @@
 }
 
 =pod
+
 =head2 MakeLondConnection
-    Create a new lond connection object, and start it towards
-    its initial idleness.  Once idle, it becomes elligible to
-    receive transactions 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 start off on it.
+
+Create a new lond connection object, and start it towards its initial
+idleness.  Once idle, it becomes elligible to receive transactions
+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
+start off on it.
+
 =cut
+
 sub MakeLondConnection {     
     Debug(4,"MakeLondConnection to ".GetServerHost()." on port "
 	  .GetServerPort());
@@ -606,17 +678,30 @@
    
     
 }
+
 =pod
+
 =head2 StartRequest
-   Starts a lond request going on a specified lond connection.
-    parameters are:
-=item $Lond - Connection to the lond that will send the transaction
-    and receive the reply.
-=item $Client - Connection to the client that is making this request
-    We got the 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 socket.
-=item $Request - The text of the request to send.
+
+Starts a lond request going on a specified lond connection.
+parameters are:
+
+=item $Lond
+
+Connection to the lond that will send the transaction and receive the
+reply.
+
+=item $Client
+
+Connection to the client that is making this request We got the
+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
+socket.
+
+=item $Request
+
+The text of the request to send.
+
 =cut
 
 sub StartRequest {
@@ -641,19 +726,26 @@
 }
 
 =pod
+
 =head2 QueueTransaction
-    - If there is an idle lond connection, it is put to 
-    work doing this transaction.  Otherwise, the transaction is
-    placed in the work queue.  If placed in the work queue and the
-    maximum number of connections has not yet been created, a new
-    connection will be started.  Our goal is to eventually have 
-    a sufficient number of connections that the work queue will
-    typically be empty.
-    parameters are:
-=item Socket open on the lonc client.
-=item Request data to send to the lond.
+
+If there is an idle lond connection, it is put to work doing this
+transaction.  Otherwise, the transaction is placed in the work queue.
+If placed in the work queue and the maximum number of connections has
+not yet been created, a new connection will be started.  Our goal is
+to eventually have a sufficient number of connections that the work
+queue will typically be empty.  parameters are:
+
+=item Socket
+
+open on the lonc client.
+
+=item Request
+
+data to send to the lond.
 
 =cut
+
 sub QueueTransaction {
     my $requestSocket = shift;
     my $requestData   = shift;
@@ -676,10 +768,13 @@
 }
 
 #-------------------------- Lonc UNIX socket handling ---------------------
+
 =pod
+
 =head2 ClientRequest
-   Callback that is called when data can be read from the 
-   UNIX domain socket connecting us with an apache server process.
+
+Callback that is called when data can be read from the UNIX domain
+socket connecting us with an apache server process.
 
 =cut
 
@@ -716,13 +811,17 @@
 
 
 =pod
+
 =head2  NewClient
-    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 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
-    and register a new event on the readability of that socket:
+
+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
+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
+and register a new event on the readability of that socket:
+
 =cut
+
 sub NewClient {
     Debug(6, "NewClient");
     my $event      = shift;		# Get the event parameters.
@@ -744,35 +843,56 @@
     $ActiveClients{$connection} = $ClientConnection;
     $ClientConnection++;
 }
-=pod GetLoncSocketPath
-    Returns the name of the UNIX socket on which to listen for client
-    connections.
+
+=pod
+
+=head2 GetLoncSocketPath
+
+Returns the name of the UNIX socket on which to listen for client
+connections.
 
 =cut
+
 sub GetLoncSocketPath {
     return $UnixSocketDir."/".GetServerHost();
 }
 
-=pod GetServerHost 
-   Returns the host whose lond we talk with.
+=pod
+
+=head2 GetServerHost
+
+Returns the host whose lond we talk with.
+
 =cut
+
 sub GetServerHost {		# Stub - get this from config.
     return $RemoteHost;		# Setup by the fork.
 }
-=pod GetServerPort
-   Returns the lond port number.
+
+=pod
+
+=head2 GetServerPort
+
+Returns the lond port number.
+
 =cut
+
 sub GetServerPort {		# Stub - get this from config.
     return $perlvar{londPort};
 }
-=pod SetupLoncListener
-   Setup a lonc listener event.  The event is called when
-   the socket becomes readable.. that corresponds to the 
-   receipt of a new connection.  The event handler established
-   will accept the connection (creating a communcations channel), that
-   int turn will establish another event handler to subess requests.
+
+=pod
+
+=head2 SetupLoncListener
+
+Setup a lonc listener event.  The event is called when the socket
+becomes readable.. that corresponds to the receipt of a new
+connection.  The event handler established will accept the connection
+(creating a communcations channel), that int turn will establish
+another event handler to subess requests.
 
 =cut
+
 sub SetupLoncListener {
 
     my $socket;
@@ -790,6 +910,7 @@
 }
 
 =pod
+
 =head2 ChildProcess
 
 This sub implements a child process for a single lonc daemon.
@@ -875,8 +996,9 @@
 }
 
 =head1 Theory
-   The event class is used to build this as a single process with
-   an event driven model.  The following events are handled:
+
+The event class is used to build this as a single process with an
+event driven model.  The following events are handled:
 
 =item UNIX Socket connection Received
 
@@ -890,17 +1012,25 @@
 handler prevents hung connections.
 
 Key data structures:
-=item RequestQueue - A queue of requests received from UNIX sockets that are
-    waiting for a chance to be forwarded on a lond connection socket.
 
-=item ActiveConnections - A hash of lond connections that have transactions
-    in process that are available to be timed out.
+=item RequestQueue
+
+A queue of requests received from UNIX sockets that are
+waiting for a chance to be forwarded on a lond connection socket.
+
+=item ActiveConnections
+
+A hash of lond connections that have transactions in process that are
+available to be timed out.
+
+=item ActiveTransactions
+
+A hash indexed by lond connections that contain the client reply
+socket for each connection that has an active transaction on it.
+
+=item IdleConnections
+
+A hash of lond connections that have no work to do.  These connections
+can be closed if they are idle for a long enough time.
 
-=item ActiveTransactions - A hash indexed by lond connections that
-    contain the client reply socket for each connection that has an active
-    transaction on it.
-
-=item IdleConnections - A hash of lond connections that have no work
-    to do.  These connections can be closed if they are idle for a long
-    enough time.
 =cut

--albertel1050635436--