Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

connection_time: make compatible with tcpserver deployment

  • Loading branch information...
commit 086b31c546493ac23a8668633b84bb0c1ad9055b 1 parent 0e2384c
@msimerson msimerson authored abh committed
Showing with 14 additions and 4 deletions.
  1. +14 −4 plugins/connection_time
View
18 plugins/connection_time
@@ -26,9 +26,10 @@ Adjust the quantity of logging for this plugin. See docs/logging.pod
use strict;
use warnings;
-use Time::HiRes qw(gettimeofday tv_interval);
use Qpsmtpd::Constants;
+use Time::HiRes qw(gettimeofday tv_interval);
+
sub register {
my ($self, $qp) = shift, shift;
if ( @_ == 1 ) { # backwards compatible
@@ -43,18 +44,27 @@ sub register {
}
else {
$self->{_args} = { @_ }; # named args, inherits loglevel
- }
+ };
}
sub hook_pre_connection {
- my ($self, @foo) = @_;
+ my $self = shift;
+ $self->{_connection_start} = [gettimeofday];
+ $self->log(LOGDEBUG, "started at " . $self->{_connection_start} );
+ return (DECLINED);
+}
+
+sub hook_connect {
+ my $self = shift;
+# this method is needed to function with the tcpserver deployment model
+ return (DECLINED) if defined $self->{_connection_start};
$self->{_connection_start} = [gettimeofday];
$self->log(LOGDEBUG, "started at " . $self->{_connection_start} );
return (DECLINED);
}
sub hook_post_connection {
- my ($self, @foo) = @_;
+ my $self = shift;
if ( ! $self->{_connection_start} ) {
$self->log(LOGERROR, "Start time not set?!");
Please sign in to comment.
Something went wrong with that request. Please try again.