-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: stop services after transports #1138
Conversation
Looking a the errors I agree it would make sense to close services after transports though. Maybe the services close resources they should not? |
I'm surprised that the tests failed. |
@lchenut
|
this fixes the tests, but not sure if it's the right way of doing it: if not self.onReservation.isNil() and self.relayAddresses.len > 0 and switch.started:
self.onReservation(concat(toSeq(self.relayAddresses.values))) |
It looks good to me. It should probably be necessary to write a similar condition here aswell
|
Why is |
|
nim-libp2p/libp2p/services/autorelayservice.nim Lines 57 to 58 in 100f318
Here onReservation is called because we just connect someone and made a reservation, so we send an up to date list of address.nim-libp2p/libp2p/services/autorelayservice.nim Lines 98 to 99 in 100f318
Here onReservation is called because some remote peer just disconnect or close connection, so we send an up to date list of address.
|
And One thing you could do to prevent this behavior is to add a fifth state in But to be perfectly honest, I'm not 100% certain this PR is useful. My gut feeling says that we should stop Services (which indirectly uses the Transport) before closing the Transports. |
I think you're right and I'll probably close it.
So |
I agree that onReservation name could be misleading. Autorelay Service's test handles this specific case, it's the |
Could you elaborate on what is weird in your opinion? |
Let's take an example:
I find it weird because we are stopping SwitchA. So we know we are disconnecting. I'm not sure it's a relevant point to indicate, after you decide to stop that, you indeed stopped. It's redundant. |
I'm going to close this PR, we should stop the services first. One way to think about it is we start "things" and add them to an imaginary stack. When we want to stop them, we pop and stop, i.e. we stop in the reserve order that they were added. See #1095 (comment). Even after this PR is closed and the tests pass, the service remains brittle if it behaves unexpectedly when unrelated changes occur. |
#843 Services stop duplication, but services should be stopped after Transports, as they are higher level.