Skip to content
This repository
Browse code

connection_time: make compatible with tcpserver deployment

  • Loading branch information...
commit 086b31c546493ac23a8668633b84bb0c1ad9055b 1 parent 0e2384c
Matt Simerson authored June 03, 2012 abh committed June 04, 2012

Showing 1 changed file with 14 additions and 4 deletions. Show diff stats Hide diff stats

  1. 18  plugins/connection_time
18  plugins/connection_time
@@ -26,9 +26,10 @@ Adjust the quantity of logging for this plugin. See docs/logging.pod
26 26
 use strict;
27 27
 use warnings;
28 28
 
29  
-use Time::HiRes qw(gettimeofday tv_interval);
30 29
 use Qpsmtpd::Constants;
31 30
 
  31
+use Time::HiRes qw(gettimeofday tv_interval);
  32
+
32 33
 sub register {
33 34
     my ($self, $qp) = shift, shift;
34 35
     if ( @_ == 1 ) {              # backwards compatible
@@ -43,18 +44,27 @@ sub register {
43 44
     }
44 45
     else {
45 46
         $self->{_args} = { @_ };     # named args, inherits loglevel
46  
-    }
  47
+    };
47 48
 }
48 49
 
49 50
 sub hook_pre_connection {
50  
-    my ($self, @foo) = @_;
  51
+    my $self = shift;
  52
+    $self->{_connection_start} = [gettimeofday];
  53
+    $self->log(LOGDEBUG, "started at " . $self->{_connection_start} );
  54
+    return (DECLINED);
  55
+}
  56
+
  57
+sub hook_connect {
  58
+    my $self = shift;
  59
+# this method is needed to function with the tcpserver deployment model
  60
+    return (DECLINED) if defined $self->{_connection_start};
51 61
     $self->{_connection_start} = [gettimeofday];
52 62
     $self->log(LOGDEBUG, "started at " . $self->{_connection_start} );
53 63
     return (DECLINED);
54 64
 }
55 65
 
56 66
 sub hook_post_connection {
57  
-    my ($self, @foo) = @_;
  67
+    my $self = shift;
58 68
 
59 69
     if ( ! $self->{_connection_start} ) {
60 70
         $self->log(LOGERROR, "Start time not set?!");

0 notes on commit 086b31c

Please sign in to comment.
Something went wrong with that request. Please try again.