Revision: 76
Author:   matt
Date:     2006-08-11 20:42:18 +0000 (Fri, 11 Aug 2006)

Log Message:
-----------
Add leak detection code (commented out for now)

Modified Paths:
--------------
    trunk/lib/AxKit2/Connection.pm

Modified: trunk/lib/AxKit2/Connection.pm
===================================================================
--- trunk/lib/AxKit2/Connection.pm      2006-08-11 20:40:00 UTC (rev 75)
+++ trunk/lib/AxKit2/Connection.pm      2006-08-11 20:42:18 UTC (rev 76)
@@ -182,6 +182,18 @@
     );
     
     $self->write(sub { $self->http_response_sent() });
+
+#    use Devel::GC::Helper;
+#    use Data::Dumper;
+#    $Data::Dumper::Terse = 1;
+#    $Data::Dumper::Indent = 1;
+#    #$Data::Dumper::Deparse = 1;
+#    my $leaks = Devel::GC::Helper::sweep;
+#    foreach my $leak (@$leaks) {
+#        print "Leaked $leak\n";
+#        print Dumper($leak);
+#    }
+#    print "Total leaks: " . scalar(@$leaks) . "\n";                           
                      
 }
 
 # called when we've finished writing everything to a client and we need
@@ -239,6 +251,8 @@
 sub _do_cleanup {
     my $now = time;
     
+    # AxKit2::Client->log(LOGDEBUG, "do cleanup");
+    
     Danga::Socket->AddTimer(CLEANUP_TIME, \&_do_cleanup);
     
     my $sf = __PACKAGE__->get_sock_ref;
@@ -254,13 +268,16 @@
             $max_age{$ref}      = $ref->max_idle_time || 0;
             $max_connect{$ref}  = $ref->max_connect_time || 0;
         }
+        AxKit2::Client->log(LOGDEBUG, "got a Connection. Max age: 
$max_age{$ref}, Max Connect: $max_connect{$ref}");
         if (my $t = $max_connect{$ref}) {
+            AxKit2::Client->log(LOGDEBUG, "connection time: $v->{create_time} 
< " . ($now - $t));
             if ($v->{create_time} < $now - $t) {
                 push @to_close, $v;
                 next;
             }
         }
         if (my $t = $max_age{$ref}) {
+            AxKit2::Client->log(LOGDEBUG, "alive time: $v->{alive_time} < " . 
($now - $t));
             if ($v->{alive_time} < $now - $t) {
                 push @to_close, $v;
             }


Reply via email to