Annotation of loncom/LondTransaction.pm, revision 1.7

1.1       foxr        1: #   This module defines and implements a class that represents
                      2: #   a connection to a lond daemon.
                      3: #
1.7     ! foxr        4: # $Id: LondTransaction.pm,v 1.6 2003/09/15 09:26:17 foxr Exp $
1.1       foxr        5: #
                      6: # Copyright Michigan State University Board of Trustees
                      7: #
                      8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
                      9: #
                     10: # LON-CAPA is free software; you can redistribute it and/or modify
                     11: # it under the terms of the GNU General Public License as published by
                     12: # the Free Software Foundation; either version 2 of the License, or
                     13: # (at your option) any later version.
                     14: #
                     15: # LON-CAPA is distributed in the hope that it will be useful,
                     16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
                     17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     18: # GNU General Public License for more details.
                     19: #
                     20: # You should have received a copy of the GNU General Public License
                     21: # along with LON-CAPA; if not, write to the Free Software
                     22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     23: #
                     24: # /home/httpd/html/adm/gpl.txt
                     25: #
                     26: # http://www.lon-capa.org/
                     27: #
                     28: 
                     29: =pod
1.3       foxr       30: 
                     31: =head1 Synopsis
                     32: 
1.2       foxr       33:   LondTransaction objectifies the state of a transaction between lonc and
1.1       foxr       34:   lond (loncnew really).  
                     35: 
                     36: =cut
                     37: 
1.6       foxr       38: use strict;
                     39: 
1.3       foxr       40: package LondTransaction;
1.2       foxr       41: 
                     42: =pod
                     43: =head1 Description
                     44: 
                     45: LondTransaction objects hold the state required to manage a 
                     46: transaction between lonc and lond, from the loncnew point of view.
                     47: The state consists of the following member data:
                     48: 
                     49: =item request
                     50: 
                     51: The text of the request to send to lond.
                     52: 
                     53: =item active
                     54: 
                     55: If zero, the request is not active and the londSocket item is not
                     56: defined.
                     57: 
                     58: =item londSocket
                     59: 
1.3       foxr       60: If the request is active,
1.2       foxr       61: this member contains the LondConnection object reference that
                     62: this request is being processed on.
                     63: 
                     64: =item deferred
                     65: 
                     66: True if the request is a deferred (delayed) request.
                     67: The member data below are either present or not depending on 
                     68: whether or not deferred is true.
                     69: 
                     70: =item clientSocket
                     71:    
                     72: If deferred is false, this member data is defined and is the 
                     73: handle to the socket that is connected to the apache child that
                     74: has requested this transaction.
                     75: 
                     76: =item DeferredFile
                     77: 
                     78: If deferred is false, this member data is defined and is the name
                     79: of the file that contains the deferred request.  When the transaction
                     80: is retired, this file will be deleted.
                     81: 
                     82: =head1 Member Functions
                     83: 
                     84: =head2  Operational functions
                     85: 
1.3       foxr       86: =cut
                     87: 
                     88: =pod
                     89: 
1.2       foxr       90: =item new
                     91: 
                     92: Creates a new transaction object.
                     93: 
1.3       foxr       94: =cut
1.6       foxr       95: 
                     96: 
1.3       foxr       97: 
                     98: sub new {
1.7     ! foxr       99: 
        !           100:     my ($class, $Transaction) = @_;
1.3       foxr      101: 
                    102:     
                    103:     my $self   = {request     => $Transaction,
                    104: 		  active      => 0,
                    105: 		  deferred    => 0};
                    106:     bless($self, $class);
1.5       foxr      107:     return $self;
1.3       foxr      108: }
                    109: =pod
                    110: 
1.2       foxr      111: =item Activate
                    112: 
                    113: Activates the transaction by assigning it to a LondConnection object
                    114: 
1.3       foxr      115: Parameters:
                    116: 
                    117: =over 3
                    118: 
                    119: =item  Connection
                    120: 
                    121: 
                    122: Reference to the LondConnection object along which the transaction
                    123: will be carried.
                    124: 
                    125: =back 
                    126: 
                    127: =cut
                    128: sub Activate {
1.7     ! foxr      129: 
        !           130: 
        !           131:     my ($self, $Connection) = @_;
        !           132: 
1.3       foxr      133: 
                    134:     $self->{londSocket} = $Connection; # Store the connection object and
                    135:     $self->{active}     = 1;	       # Indicate it's active.
                    136: 
                    137: }
                    138: 
                    139: =pod
                    140: 
1.2       foxr      141: =item Retire
                    142: 
1.3       foxr      143: 
                    144: Retires a transaction after successful completion.  If the
                    145: transaction is deferred, the deferred file is destroyed.
                    146: Otherwise this is a noop.
                    147: 
                    148: =cut
                    149: sub Retire {
                    150:     my $self     = shift;
                    151: 
                    152:     if($self->{deferred}) {
                    153: 	unlink $self->{DeferredFile};
                    154:     }
                    155: 
                    156:     #  Destroy my member data to release reference counts.
                    157: 
                    158:     delete $self->{londSocket};
                    159:     delete $self->{clientSocket};
                    160:     delete $self->{DeferredFile};
                    161: 
                    162: }
                    163: 
                    164: =pod
1.2       foxr      165: 
                    166: =item SetDeferred
                    167: 
                    168: Sets the state of a transaction to deferred, the deferred member
                    169: is set true, clientSocket is undefined, and DeferredFile is set.
                    170: 
1.3       foxr      171: Parameters:
                    172:  
                    173: =over 3
                    174: 
                    175: =item File
                    176: 
                    177: Name of the file that holds the deferred transaction.
                    178: 
                    179: =back 
                    180: 
                    181: =cut
                    182: sub SetDeferred {
1.7     ! foxr      183: 
        !           184: 
        !           185:     my ($self, $File) = @_;
1.3       foxr      186: 
                    187:     $self->{deferred}      = 1;
1.5       foxr      188:     $self->{DeferredFile} = $File;
1.3       foxr      189: }
                    190: 
                    191: =pod
                    192: 
                    193: =item  SetClient
1.2       foxr      194: 
                    195: Sets the state of a transaction to not deferred.  The deferred member
                    196: is set false, clientSocket is set and DeferredFile is undefined.
                    197: 
1.3       foxr      198: Parameters:
                    199: 
                    200: =over 3
                    201: 
                    202: =item Socket
                    203: 
                    204:   The socket open on the client.
                    205: 
                    206: =back
                    207: 
                    208: =cut
                    209: sub SetClient {
1.7     ! foxr      210: 
        !           211:     my ($self, $Client) = @_;
1.3       foxr      212:     
                    213:     $self->{deferred}     = 0;
                    214:     $self->{clientSocket} = $Client; 
                    215: }
                    216: 
                    217: =pod
                    218: 
1.2       foxr      219: =head2  Selectors
                    220: 
                    221: 
                    222: =item isDeferred
                    223: 
                    224: Returns the state of the deferred member.
                    225: 
1.3       foxr      226: =cut
                    227: sub isDeferred {
                    228:     my $self   = shift;
                    229:     return $self->{deferred};
                    230: }
                    231: 
                    232: =pod
                    233: 
1.2       foxr      234: =item isActive
                    235: 
1.3       foxr      236: Returns the value of the active member.
                    237: 
                    238: =cut
                    239: sub isActive {
                    240:     my $self = shift;
                    241:     return $self->{active};
                    242: }
                    243: 
                    244: =pod
1.2       foxr      245: 
                    246: =item getClient
                    247: 
1.3       foxr      248: If not deferred returns the client socket, else returns undef.
                    249: 
                    250: =cut
                    251: sub getClient {
                    252:     my $self = shift;
                    253:     if($self->{deferred}) {
                    254: 	return undef;
                    255:     } else {
                    256: 	return $self->{clientSocket};
                    257:     }
                    258: }
                    259: 
                    260: 
                    261: =pod
1.2       foxr      262: 
                    263: =item getFile
                    264: 
                    265: If deferred, returns the name of the deferred queue file else
                    266: returns undef.
                    267: 
                    268: =cut
1.3       foxr      269: sub getFile {
                    270:     my $self = shift;
                    271:     if($self->{deferred}) {
                    272: 	return $self->{DeferredFile};
                    273:     } else {
                    274: 	return undef;
                    275:     }
                    276: }
                    277: 
                    278: 
                    279: =pod
                    280: 
                    281: =item getServer
                    282: 
                    283:   If active returns the lond server socket else undef.
                    284: 
                    285: =cut
                    286: sub getServer {
                    287:     my $self  = shift;
                    288: 
                    289:     if($self->{active}) {
                    290: 	return $self->{londSocket};
                    291:     } else {
                    292: 	return undef;
                    293:     }
                    294: }
                    295: 
                    296: =pod
                    297: 
                    298: =item getRequest
                    299: 
                    300:   Returns the remaining request text.
                    301: 
                    302: =cut
                    303: sub getRequest {
                    304:     my $self = shift;
                    305:     return $self->{request};
                    306: }
                    307: 
                    308: 
1.5       foxr      309: 1;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.