diff options
| author | fukachan <fukachan> | 2004-05-16 04:55:55 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2004-05-16 04:55:55 +0000 |
| commit | 4ffff2c90ae600e86b40f77d4b09078313d9a62d (patch) | |
| tree | 96793eead645accf7bda5f758552e164ccec9d04 | |
| parent | e76e8bbc547ba1677d0e688a42d5a0d8d904868c (diff) | |
| download | fml8-4ffff2c90ae600e86b40f77d4b09078313d9a62d.tar.gz fml8-4ffff2c90ae600e86b40f77d4b09078313d9a62d.tar.bz2 fml8-4ffff2c90ae600e86b40f77d4b09078313d9a62d.zip | |
rollback if DATA error occurs.
rename _get_*() -> get_*(), _set_*() -> set_*() since private methods
should not be shared over modules.
| -rw-r--r-- | fml/lib/Mail/Delivery/SMTP.pm | 34 | ||||
| -rw-r--r-- | fml/lib/Mail/Delivery/Utils.pm | 58 |
2 files changed, 48 insertions, 44 deletions
diff --git a/fml/lib/Mail/Delivery/SMTP.pm b/fml/lib/Mail/Delivery/SMTP.pm index 324ca0b0..baf12da3 100644 --- a/fml/lib/Mail/Delivery/SMTP.pm +++ b/fml/lib/Mail/Delivery/SMTP.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: SMTP.pm,v 1.23 2003/08/23 04:35:45 fukachan Exp $ +# $FML: SMTP.pm,v 1.24 2004/01/24 09:03:58 fukachan Exp $ # @@ -211,7 +211,7 @@ sub _read_reply } # store the latest status code - if ($buf =~ /^(\d{3})/) { $self->_set_status_code($1);} + if ($buf =~ /^(\d{3})/) { $self->set_status_code($1);} # check status code if ($buf =~ /^[45]\d{2}\s/) { @@ -443,9 +443,9 @@ sub deliver next MAP; } - $self->_set_target_map($map); - $self->_set_map_status($map, 'not done'); - $self->_set_map_position($map, 0); + $self->set_target_map($map); + $self->set_map_status($map, 'not done'); + $self->set_map_position($map, 0); # XXX-TODO: correct $max_loop_count evaluation ? # To avoid infinite loop, we enforce some artificial limit. @@ -480,13 +480,13 @@ sub deliver $self->error_clear; # we read the whole $map now. - if ($self->_get_map_status($map) eq 'done') { + if ($self->get_map_status($map) eq 'done') { last MTA; } } # end of MTA: loop # end of MTA_RETRY_LOOP: loop - if ($self->_get_map_status($map) eq 'done') { + if ($self->get_map_status($map) eq 'done') { last MTA_RETRY_LOOP; } @@ -580,7 +580,11 @@ sub _deliver # IF_ERROR_FOUND: handled in _send_data_to_mta(), so # return as soon as possible from here. $self->_send_data_to_mta($args); - if ($self->error) { return;} + if ($self->error) { + $self->_rollback_map_position; + $self->_reset_smtp_transaction; + return; + } # 6. QUIT; SMTP session closing ... # IF_ERROR_FOUND: do nothing ? @@ -648,7 +652,7 @@ sub _send_mail_from sub _send_recipient_list_by_recipient_map { my ($self, $args) = @_; - my $map = $self->_get_target_map; + my $map = $self->get_target_map; # open abstract recipient list objects. # $map syntax is "type:parameter", e.g., @@ -670,8 +674,8 @@ sub _send_recipient_list_by_recipient_map }; # roll back the previous file offset - if ($self->_get_map_position($map) > 0) { - $obj->setpos( $self->_get_map_position($map) ); + if ($self->get_map_position($map) > 0) { + $obj->setpos( $self->get_map_position($map) ); } # XXX $obj->get_recipient returns a mail address. @@ -690,11 +694,11 @@ sub _send_recipient_list_by_recipient_map } # save the current position in the file handle - $self->_set_map_position($map, $obj->getpos); + $self->set_map_position($map, $obj->getpos); # done. if ($obj->eof) { - $self->_set_map_status($map, 'done'); + $self->set_map_status($map, 'done'); } # ends @@ -721,7 +725,7 @@ sub _send_recipient_list my ($self, $args) = @_; # evaluate recipient_maps - if ( $self->_get_target_map ) { + if ( $self->get_target_map ) { $self->_send_recipient_list_by_recipient_map($args); } } @@ -788,7 +792,7 @@ sub _send_data_to_mta $self->_read_reply; # XXX if "DATA" transaction cannot start, retry ? - if ($self->_get_status_code != '354' || $self->error) { + if ($self->get_status_code != '354' || $self->error) { Log($self->error); return undef; } diff --git a/fml/lib/Mail/Delivery/Utils.pm b/fml/lib/Mail/Delivery/Utils.pm index 9db40773..b0f4c57d 100644 --- a/fml/lib/Mail/Delivery/Utils.pm +++ b/fml/lib/Mail/Delivery/Utils.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Utils.pm,v 1.14 2003/12/29 07:31:30 fukachan Exp $ +# $FML: Utils.pm,v 1.15 2004/01/24 09:03:58 fukachan Exp $ # package Mail::Delivery::Utils; @@ -29,15 +29,15 @@ require Exporter; error error_clear - _set_status_code - _get_status_code + set_status_code + get_status_code - _set_target_map - _get_target_map - _set_map_status - _set_map_position - _get_map_status - _get_map_position + set_target_map + get_target_map + set_map_status + set_map_position + get_map_status + get_map_position _rollback_map_position _reset_mapinfo ); @@ -188,11 +188,11 @@ reset the error buffer which C<error_set()> and C<error()> use. ##### status codes manipulations ##### -=head2 _set_status_code($value) +=head2 set_status_code($value) save C<($value)> as status code. -=head2 _get_status_code() +=head2 get_status_code() get the latest status code. @@ -206,7 +206,7 @@ get the latest status code. # Arguments: OBJ($self) # Side Effects: none # Return Value: STR -sub _get_status_code +sub get_status_code { my ($self) = @_; @@ -220,7 +220,7 @@ sub _get_status_code # Arguments: OBJ($self) STR($value) # Side Effects: update object # Return Value: STR -sub _set_status_code +sub set_status_code { my ($self, $value) = @_; @@ -237,12 +237,12 @@ sub _set_status_code =head1 METHODS TO HANDLE POSITION at IO MAP -=head2 _set_target_map($map) +=head2 set_target_map($map) save the current C<map> name where C<map> is a name usable at C<recipient_maps> -=head2 _get_target_map() +=head2 get_target_map() return the current C<map> where C<map> is a name usable at C<recipient_maps> @@ -254,7 +254,7 @@ where C<map> is a name usable at C<recipient_maps> # Arguments: OBJ($self) STR($map) # Side Effects: update object # Return Value: STR -sub _set_target_map +sub set_target_map { my ($self, $map) = @_; @@ -266,7 +266,7 @@ sub _set_target_map # Arguments: OBJ($self) # Side Effects: none # Return Value: STR -sub _get_target_map +sub get_target_map { my ($self) = @_; @@ -276,20 +276,20 @@ sub _get_target_map } -=head2 _set_map_status($map, $status) +=head2 set_map_status($map, $status) save C<$status> for C<$map> IO. For example, C<$status> is 'not done'. -=head2 _set_map_position($map, $position) +=head2 set_map_position($map, $position) save the C<$position> for C<$map> IO. -=head2 _get_map_status($map) +=head2 get_map_status($map) get the current C<$status> for C<$map> IO. -=head2 _get_map_position($map) +=head2 get_map_position($map) get the current C<$position> for C<$map> IO. @@ -300,7 +300,7 @@ get the current C<$position> for C<$map> IO. # Arguments: OBJ($self) STR($map) STR($status) # Side Effects: update object # Return Value: STR -sub _set_map_status +sub set_map_status { my ($self, $map, $status) = @_; $self->{ _mapinfo }->{ $map }->{prev_status} = @@ -313,7 +313,7 @@ sub _set_map_status # Arguments: OBJ($self) STR($map) STR($position) # Side Effects: update object # Return Value: STR -sub _set_map_position +sub set_map_position { my ($self, $map, $position) = @_; $self->{ _mapinfo }->{ $map }->{prev_position} = @@ -326,7 +326,7 @@ sub _set_map_position # Arguments: OBJ($self) STR($map) # Side Effects: update object # Return Value: STR -sub _get_map_status +sub get_map_status { my ($self, $map) = @_; @@ -340,7 +340,7 @@ sub _get_map_status # Arguments: OBJ($self) STR($map) # Side Effects: update object # Return Value: STR -sub _get_map_position +sub get_map_position { my ($self, $map) = @_; @@ -370,7 +370,7 @@ clear information around the latest map operation. sub _rollback_map_position { my ($self) = @_; - my $map = $self->_get_target_map; + my $map = $self->get_target_map; # count the number of rollback to avoid infinite loop if ( $self->{ _map_rollback_info }->{ $map }->{ count } > 2 ) { @@ -383,12 +383,12 @@ sub _rollback_map_position my $prev_pos = $self->{ _mapinfo }->{ $map }->{prev_position}; my $pos = $self->{ _mapinfo }->{ $map }->{position}; - $self->_set_map_position($map, $prev_pos); + $self->set_map_position($map, $prev_pos); Log("Info: rollback $map from $pos to $prev_pos"); my $prev_status = $self->{ _mapinfo }->{ $map }->{prev_status}; my $status = $self->{ _mapinfo }->{ $map }->{status}; - $self->_set_map_status($map, $prev_status); + $self->set_map_status($map, $prev_status); Log("Info: rollback status of $map to '$prev_status'"); } @@ -400,7 +400,7 @@ sub _rollback_map_position sub _reset_mapinfo { my ($self) = @_; - $self->_set_target_map(''); + $self->set_target_map(''); delete $self->{ _mapinfo }; delete $self->{ _map_rollback_info }; } |
