Skip to content

fix: Flush the UnityTransport send queue on shutdown #1234

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

Merged
merged 4 commits into from
Sep 30, 2021

Conversation

simon-lemay-unity
Copy link
Contributor

When NetworkManager.Shutdown is called, all clients are disconnected and the transport is immediately shut down. For UnityTransport, that means disconnect messages are not actually sent to the remote peers, because nothing goes out on the wire until an internal update of the driver is scheduled (which doesn't happen between the disconnect calls and the transport's shutdown).

This is fixed by flushing the internal send queue when shutting down the transport. This will send out any disconnect messages that might still be pending. The downside is that UnityTransport.Shutdown might take a bit longer to execute, since it will need to perform network activity. But when you're shutting down, you're presumably not in a situation where performance is critical, so this is probably acceptable.

When NetworkManager.Shutdown is called, all clients are disconnected and
the transport is immediately shut down. For UnityTransport, that means
disconnect messages are not actually sent to the remote peers, because
nothing goes out on the wire until an internal update of the driver is
scheduled (which doesn't happen between the disconnect calls and the
transport's shutdown).

This is fixed by flushing the internal send queue when shutting down the
transport. This will send out any disconnect messages that might still
be pending. The downside is that UnityTransport.Shutdown might take a
bit longer to execute, since it will need to perform network activity.
But when you're shutting down, you're presumably not in a situation
where performance is critical, so this is probably acceptable.
@andrews-unity andrews-unity merged commit 4e0dfd5 into develop Sep 30, 2021
@andrews-unity andrews-unity deleted the fix/shutdown-flush-send branch September 30, 2021 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants