]> dxcluster.org Git - spider.git/commitdiff
simplified the disconnect even more
authorDirk Koopman <djk@tobit.co.uk>
Tue, 21 Apr 2020 19:13:39 +0000 (20:13 +0100)
committerDirk Koopman <djk@tobit.co.uk>
Tue, 21 Apr 2020 19:13:39 +0000 (20:13 +0100)
And now added some working debugging and put back bye.pl so that
it doesn't call Mojo directly.

Simplified the whole thing. Now let's see whether that has a memory leak

cmd/bye.pl
perl/Msg.pm

index c974799ea9d1034ef41863de6f2cde27cda42ced..d43e257a5aa21d91ff1146aaea4a45ce9e0fc549 100644 (file)
@@ -13,9 +13,8 @@ dbg("fn: $fn " . (-e $fn ? 'exists' : 'missing'));
 
 if ($self->is_user && -e $fn) {
        $self->send_file($fn);
-       Mojo::IOLoop->timer($Msg::disc_waittime, sub{$self->disconnect});
-} else {
-       $self->disconnect;
 }
 
+$self->disconnect;
+
 return (1);
index aa9993e7ff966bf2b15ae5d3dc9782e96a421271..4400fe8d76482050f5d8974b599a6fcdeed55559 100644 (file)
@@ -28,7 +28,7 @@ $now = time;
 
 $cnum = 0;
 $connect_timeout = 5;
-$disc_waittime = 3;
+$disc_waittime = 1.5;
 
 our %delqueue;
 
@@ -276,14 +276,16 @@ sub disconnect
        $delqueue{$conn} = $conn; # save this connection until everything is finished
        my $sock = $conn->{sock};
        if ($sock) {
-
-               # remove me from the active list
-               my $call;
-               if ($call = $conn->{call}) {
-                       my $ref = $conns{$call};
-                       delete $conns{$call} if $ref && $ref == $conn;
+               if ($sock->{buffer}) {
+                       my $lth = length $sock->{buffer};
+                       Mojo::IOLoop->timer($disc_waittime, sub {
+                                                                       dbg("Buffer contained $lth data , coordinated for $disc_waittime secs, now disconnecting $call") if $dbg;
+                                                                       _close_it($conn);
+                                                               });
+               } else {
+                       dbg("Buffer empty, just close $call") if $dbg;
+                       _close_it($conn);
                }
-               _close_it($conn);
        } else {
                dbg((ref $conn) . " socket missing on $conn->{call}") if $dbg;
                _close_it($conn);