That waiting is necessary to clean up all upstream handling of the old connection and ensure that the Delete() from the map is the concerning connection, and not already the new connection, still breaking downlink.
Can you do this yourself and submit a Pull Request?
Summary
New connections overwrite existing connections
Steps to Reproduce
What do you see now?
Gateway Server maps the connections by UID and removes entries on gateway disconnects, while there may be another gateway connected. This can be due to an unclean disconnect or anything else. References https://github.com/TheThingsNetwork/lorawan-stack/issues/1729 and probably #1730 (and probably https://github.com/TheThingsIndustries/lorawan-stack/issues/1735).
What do you want to see instead?
Actively disconnect existing connections when a gateway connects.
How do you propose to implement this?
https://github.com/TheThingsNetwork/lorawan-stack/blob/master/pkg/gatewayserver/gatewayserver.go#L415
Here we probably want a loop that does a
LoadOrStore()
, and as long as there's a connection loaded, disconnect it and wait for that connection. You can close a signaling channel here: https://github.com/TheThingsNetwork/lorawan-stack/blob/master/pkg/gatewayserver/gatewayserver.go#L476That waiting is necessary to clean up all upstream handling of the old connection and ensure that the
Delete()
from the map is the concerning connection, and not already the new connection, still breaking downlink.Can you do this yourself and submit a Pull Request?
Can review, can do