CC: | david.lillie [...] morganstanley.com,merijn.broeren [...] morganstanley.com |
Subject: | PoCo::Client::TCP sometimes doesn't send Disconnected callback |
When handling a shutdown event, PoCo::Client::TCP will call the user's
Disconnected callback only if "not $heap->{server}-
Show quoted text
>get_driver_out_octets()" -- i.e., if there's no buffered output.
Let's say you want to explicitly close the TCP connection, so you do:
$poe_kernel->call ($tcp_session, 'shutdown');
This will lead to the connection getting torn down, but if there is
buffered output at the time, the shutdown event won't call
$disc_callback, and it doesn't look like there's any provision for
doing it later (after the output buffer gets flushed).
I think the fix is to replace this line in got_server_flush:
delete $heap->{server} if $heap->{shutdown};
with:
if ($heap->{shutdown}) {
delete $heap->{server};
$disc_callback->(@_);
}
so got_server_flush cleans up after shutdown in this case.