version 1.2, 2003/05/05 23:58:05
|
version 1.8, 2005/06/16 22:33:45
|
Line 27
|
Line 27
|
# |
# |
|
|
=pod |
=pod |
=HEAD1 Synopsis |
|
|
=head1 Synopsis |
|
|
LondTransaction objectifies the state of a transaction between lonc and |
LondTransaction objectifies the state of a transaction between lonc and |
lond (loncnew really). |
lond (loncnew really). |
|
|
=cut |
=cut |
|
|
|
use strict; |
|
|
|
package LondTransaction; |
|
|
=pod |
=pod |
=head1 Description |
=head1 Description |
Line 52 defined.
|
Line 57 defined.
|
|
|
=item londSocket |
=item londSocket |
|
|
If the request is not a deferred one (deferred = false), |
If the request is active, |
this member contains the LondConnection object reference that |
this member contains the LondConnection object reference that |
this request is being processed on. |
this request is being processed on. |
|
|
Line 78 is retired, this file will be deleted.
|
Line 83 is retired, this file will be deleted.
|
|
|
=head2 Operational functions |
=head2 Operational functions |
|
|
|
=cut |
|
|
|
=pod |
|
|
=item new |
=item new |
|
|
Creates a new transaction object. |
Creates a new transaction object. |
|
|
|
=cut |
|
|
|
|
|
|
|
sub new { |
|
|
|
my ($class, $Transaction) = @_; |
|
|
|
|
|
my $self = {request => $Transaction, |
|
active => 0, |
|
deferred => 0}; |
|
bless($self, $class); |
|
return $self; |
|
} |
|
=pod |
|
|
=item Activate |
=item Activate |
|
|
Activates the transaction by assigning it to a LondConnection object |
Activates the transaction by assigning it to a LondConnection object |
|
|
|
Parameters: |
|
|
|
=over 3 |
|
|
|
=item Connection |
|
|
|
|
|
Reference to the LondConnection object along which the transaction |
|
will be carried. |
|
|
|
=back |
|
|
|
=cut |
|
sub Activate { |
|
|
|
|
|
my ($self, $Connection) = @_; |
|
|
|
|
|
$self->{londSocket} = $Connection; # Store the connection object and |
|
$self->{active} = 1; # Indicate it's active. |
|
|
|
} |
|
|
|
=pod |
|
|
=item Retire |
=item Retire |
|
|
Retires a transaction after successful completion. |
|
|
Retires a transaction after successful completion. If the |
|
transaction is deferred, the deferred file is destroyed. |
|
Otherwise this is a noop. |
|
|
|
=cut |
|
sub Retire { |
|
my $self = shift; |
|
|
|
if($self->{deferred}) { |
|
unlink $self->{DeferredFile}; |
|
} |
|
|
|
# Destroy my member data to release reference counts. |
|
|
|
delete $self->{londSocket}; |
|
delete $self->{clientSocket}; |
|
delete $self->{DeferredFile}; |
|
|
|
} |
|
|
|
=pod |
|
|
=item SetDeferred |
=item SetDeferred |
|
|
Sets the state of a transaction to deferred, the deferred member |
Sets the state of a transaction to deferred, the deferred member |
is set true, clientSocket is undefined, and DeferredFile is set. |
is set true, clientSocket is undefined, and DeferredFile is set. |
|
|
=item SetClient |
Parameters: |
|
|
|
=over 3 |
|
|
|
=item File |
|
|
|
Name of the file that holds the deferred transaction. |
|
|
|
=back |
|
|
|
=cut |
|
sub SetDeferred { |
|
|
|
|
|
my ($self, $File) = @_; |
|
|
|
$self->{deferred} = 1; |
|
$self->{DeferredFile} = $File; |
|
} |
|
|
|
=pod |
|
|
|
=item SetClient |
|
|
Sets the state of a transaction to not deferred. The deferred member |
Sets the state of a transaction to not deferred. The deferred member |
is set false, clientSocket is set and DeferredFile is undefined. |
is set false, clientSocket is set and DeferredFile is undefined. |
|
|
|
Parameters: |
|
|
|
=over 3 |
|
|
|
=item Socket |
|
|
|
The socket open on the client. |
|
|
|
=back |
|
|
|
=cut |
|
sub SetClient { |
|
|
|
my ($self, $Client) = @_; |
|
|
|
$self->{deferred} = 0; |
|
$self->{clientSocket} = $Client; |
|
} |
|
|
|
=pod |
|
|
=head2 Selectors |
=head2 Selectors |
|
|
|
|
Line 107 is set false, clientSocket is set and De
|
Line 223 is set false, clientSocket is set and De
|
|
|
Returns the state of the deferred member. |
Returns the state of the deferred member. |
|
|
|
=cut |
|
sub isDeferred { |
|
my $self = shift; |
|
return $self->{deferred}; |
|
} |
|
|
|
=pod |
|
|
=item isActive |
=item isActive |
|
|
Returns the staate of the active member. |
Returns the value of the active member. |
|
|
|
=cut |
|
sub isActive { |
|
my $self = shift; |
|
return $self->{active}; |
|
} |
|
|
|
=pod |
|
|
=item getClient |
=item getClient |
|
|
if not deferred returns the client socket, else returns undef. |
If not deferred returns the client socket, else returns undef. |
|
|
|
=cut |
|
sub getClient { |
|
my $self = shift; |
|
if($self->{deferred}) { |
|
return undef; |
|
} else { |
|
return $self->{clientSocket}; |
|
} |
|
} |
|
|
|
|
|
=pod |
|
|
=item getFile |
=item getFile |
|
|
Line 121 If deferred, returns the name of the def
|
Line 266 If deferred, returns the name of the def
|
returns undef. |
returns undef. |
|
|
=cut |
=cut |
|
sub getFile { |
|
my $self = shift; |
|
if($self->{deferred}) { |
|
return $self->{DeferredFile}; |
|
} else { |
|
return undef; |
|
} |
|
} |
|
|
|
|
|
=pod |
|
|
|
=item getServer |
|
|
|
If active returns the lond server socket else undef. |
|
|
|
=cut |
|
sub getServer { |
|
my $self = shift; |
|
|
|
if($self->{active}) { |
|
return $self->{londSocket}; |
|
} else { |
|
return undef; |
|
} |
|
} |
|
|
|
=pod |
|
|
|
=item getRequest |
|
|
|
Returns the remaining request text. |
|
|
|
=cut |
|
|
|
sub getRequest { |
|
my $self = shift; |
|
return $self->{request}; |
|
} |
|
|
|
=pod |
|
|
|
=item getLoggableRequest |
|
|
|
Use this top get what the request is when you don't want to spew |
|
sensitive data into logs |
|
|
|
=cut |
|
|
|
sub getLoggableRequest { |
|
my $self = shift; |
|
my ($cmd,$subcmd)=split(':',$self->{request}); |
|
if ($cmd eq 'encrypt') { |
|
return "$cmd:$subcmd"; |
|
} |
|
return $cmd; |
|
} |
|
|
|
1; |