panic when peer disconnects
Describe the bug
I have a ratmand instance running on my home server, that I connect to from my laptop. When I checked on it the other day, the logs were full of messages like this:
Sep 02 15:04:09.090 ERROR netmod_inet: failed to send frame to peer 1: existing connection to 0 was dropped by peer
Sep 02 15:04:09.090 WARN netmod_inet::peer: Failed to send data for peer 1
thread 'Sep 02 15:04:09.090 ERROR netmod_inet: failed to send frame to peer 1: existing connection to 0 was dropped by peer
async-std/runtime' panicked at 'Sep 02 15:04:09.090 WARN netmod_inet::peer: Failed to send data for peer 1
called `Option::unwrap()` on a `None` value', Sep 02 15:04:09.090 ERROR netmod_inet: failed to send frame to peer 1: existing connection to 0 was dropped by peer
netmods/netmod-inet/src/routes.rs:54:31Sep 02 15:04:09.090 WARN netmod_inet::peer: Failed to send data for peer 1
Sep 02 15:04:09.090 ERROR netmod_inet: failed to send frame to peer 1: existing connection to 0 was dropped by peer
Sep 02 15:04:09.090 WARN netmod_inet::peer: Failed to send data for peer 1
Sep 02 15:04:09.090 ERROR netmod_inet: failed to send frame to peer 1: existing connection to 0 was dropped by peer
thread 'async-std/runtimeSep 02 15:04:09.090 WARN netmod_inet::peer: Failed to send data for peer 1
' panicked at 'called `Option::unwrap()` on a `None` value', netmods/netmod-inet/src/routes.rsSep 02 15:04:09.090 ERROR netmod_inet: failed to send frame to peer 1: existing connection to 0 was dropped by peer
:54:31Sep 02 15:04:09.090 WARN netmod_inet::peer: Failed to send data for peer 1
Sep 02 15:04:09.090 ERROR netmod_inet: failed to send frame to peer 1: existing connection to 0 was dropped by peer
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', netmods/netmod-inet/src/routes.rs:54:31
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', netmods/netmod-inet/src/routes.rs:54:31
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', netmods/netmod-inet/src/routes.rs:54:31
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', netmods/netmod-inet/src/routes.rs:54:31
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', netmods/netmod-inet/src/routes.rs:54:31
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', netmods/netmod-inet/src/routes.rs:54:31
(...repeated a lot of times...)
Component
ratmand
To Reproduce
A less-severe variant of this can be reproduced by:
- Start ratmand on peer A:
ratmand --accept-unknown-peers
- Start ratmand on peer B:
ratmand --accept-unknown-peers -p inet#10.69.69.64:9000
- Watch as they establish a connection, then hit Ctrl+C to terminate ratmand on B.
The resulting log should look something like:
Sep 05 10:43:25.526 INFO netmod_inet::server: Successfully connected with new peer #0 :)
Sep 05 10:43:27.530 INFO ratman::core::routes: Discovered new address 2AE3-D6CB-3FA4-CD8D-22F4-5E12-74CD-516E-1FB7-A1C0-8436-2837-7E09-D467-ED30-99C3
Sep 05 10:43:27.530 INFO ratman::core::routes: Discovered new address 43CC-8612-0100-E6CD-F06A-1049-948E-3DA3-94B8-3E7B-C131-BA1D-2570-2D1B-4C2D-A2CA
Sep 05 10:43:27.530 INFO ratman::core::routes: Discovered new address 7D47-AE70-ECFF-D921-8EDA-1B1F-1D9F-4017-1A9F-6F41-71A3-E411-F3C0-FA54-315D-E95E
Sep 05 10:43:32.699 WARN netmod_inet::peer: Failed to send data for peer 0
Sep 05 10:43:32.699 ERROR netmod_inet: failed to send frame to peer 0: existing connection to 0 was dropped by peer
Sep 05 10:43:32.699 WARN netmod_inet::peer: Failed to send data for peer 0
Sep 05 10:43:32.699 ERROR netmod_inet: failed to send frame to peer 0: existing connection to 0 was dropped by peer
thread 'async-std/runtime' panicked at 'called `Option::unwrap()` on a `None` value', netmods/netmod-inet/src/routes.rs:54:31
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Also, every time you then restart ratmand on B, it gets a new peer number:
Sep 05 10:44:40.685 INFO ratman::daemon: Established new client connection
Sep 05 10:44:40.692 INFO ratman::daemon::parse: API stream was dropped by client
Sep 05 10:51:45.008 INFO netmod_inet::server: Successfully connected with new peer #1 :)
But if you do it again, it doesn't seem to cause the unwrap panic:
Sep 05 10:51:54.788 WARN netmod_inet::peer: Failed to send data for peer 1
Sep 05 10:51:54.788 ERROR netmod_inet: failed to send frame to peer 1: existing connection to 0 was dropped by peer
Expected behavior
It should not do this.