Replies: 2 comments 3 replies
-
Lots to unpack here. Let me try to answer some of it.
Yes, that would be desirable. I am happy to help design such change, though I don't think driving it myself is a current priority for me. Related to this is the past graceful shutdown effort. This is harder than it seems, though I haven't looked deep enough into Roman's work to have a solid opinion. That said, I don't think this should demotivate, but instead help to gain a greater overview.
I don't quite see the concrete benefit for Another thought I had recently - still very vague- looking into #1334, is to remove the
Good catch! I don't know to be honest. Without much thought I would guess this comment is a relic of the past. Maybe @tomaka knows more? |
Beta Was this translation helpful? Give feedback.
-
I'd like to revive this discussion, because it is relevant for the implementation of AutoNAT.
I would tackle this issue, but I not too familiar with every related to the Listeners, hence I am not really sure what the best design would be. An idea would be what I suggested in the first commend above, to add a
@mxinden Is this still an desired change? And if yes, could you expand on the idea a bit more? |
Beta Was this translation helpful? Give feedback.
-
Hi,
I'd like to add some thoughts on how
ExpandedSwarm.remove_listener
is implemented, because I think it is a bit confusing.I personally would expect
remove_listener
to work analogous to howstart_listening
is behaving.For
start_listening
, a new Listener is created andSwarmEvent::NewListenAddr
are reported. This allows to verify that there is actually a new active listener.For
remove_listener
, I would expect that the Listener is closed and that there will be an eventSwarmEvent::ListenerClosed
andSwarmEvent::ExpiredListenAddr
. This is currently not the case.If I understand the current implementation correctly, it works like this:
start_listening
creates a new Listener by callingTransport.listen_on
NewAddress
, it is bubbled up and aSwarmEvent
is created for itListenersEvent::Closed
only occurs if polling the Listener returnsNone
.remove_listener
, the listener is removed from the list, hence not polled anymore. No event is created.Drop
for a Listener, to have a way of e.g. freeing allocated ports.While this allows to implement all the necessary logic, I personally think it is a bit in-transparent.
I'd like to suggest that instead the
Transport::Listener
should be required to implement a trait:Instead of dropping the listener, the
Network
would call this method.The listener can then e.g. set a local flag and return
None
inpoll_next()
, which would result in aListenersEvent::Closed
.Optionally the listener would this way also have the chance of emitting
ListenersEvent::AddressExpired
for its addresses.Another thought is that a
stop_listening
method would maybe also make sense for the Transport trait:This would also allow the transport to react to it.
For example in the memory transport, ports are registered in the
HUB
in theTransport.listen_on
method, and the de-registering happens inListener.drop()
; the HUB has to be shared in a static item. With astop_listener
method, the HUB Mutex could be a property of theMemoryTransport
and the port could be de-registered there.Btw another question in this context: the methods of
Transport
consumeself
, because according to a note:but existing transport implementations like the
MemoryTransport
andGenTcpConfig
both implement it directly. Could you point out to me why this is the case?What are your thoughts on this matter?
Beta Was this translation helpful? Give feedback.
All reactions