From f47c97d80722ed7d1881afa7caa0e8d24b6b0a75 Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Tue, 21 Apr 2020 19:43:32 +0100 Subject: [PATCH] Remove wait on drain (which may never happen) Changed the arrangements sending logout files (what a palaver for something so "simple"). Basically, if there is nothing to send on disconnect, the Mojo "drain" signal is never emitted. So it hangs for ever. But only sometimes (for some reason). --- cmd/bye.pl | 7 ++++--- perl/Msg.pm | 19 +------------------ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/cmd/bye.pl b/cmd/bye.pl index 9288d442..c974799e 100644 --- a/cmd/bye.pl +++ b/cmd/bye.pl @@ -6,15 +6,16 @@ my $self = shift; -return (1, $self->msg('e5')) if $self->inscript; +return (1, $self->msg('e5')) if $self->inscript || $self->remotecmd; my $fn = localdata("logout"); 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); diff --git a/perl/Msg.pm b/perl/Msg.pm index f3642d59..aa9993e7 100644 --- a/perl/Msg.pm +++ b/perl/Msg.pm @@ -283,24 +283,7 @@ sub disconnect my $ref = $conns{$call}; delete $conns{$call} if $ref && $ref == $conn; } - - $conn->{delay} = Mojo::IOLoop->delay ( -# Mojo::IOLoop->delay ( - sub { - my $delay = shift; - dbg("before drain $call") if $dbg; - $sock->on(drain => $delay->begin); - 1; - }, - sub { - my $delay = shift; - dbg("before _close_it $call") if $dbg; - _close_it($conn); - 1; - } - ); - $conn->{delay}->wait; - + _close_it($conn); } else { dbg((ref $conn) . " socket missing on $conn->{call}") if $dbg; _close_it($conn); -- 2.43.0