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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions com.unity.netcode.adapter.utp/Runtime/UnityTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,16 @@ public override SocketTasks StartServer()

public override void Shutdown()
{
if (!m_Driver.IsCreated)
{
return;
}

// Flush the driver's internal send queue. If we're shutting down because the
// NetworkManager is shutting down, it probably has disconnected some peer(s)
// in the process and we want to get these disconnect messages on the wire.
m_Driver.ScheduleFlushSend(default).Complete();

DisposeDriver();

foreach (var queue in m_SendQueue.Values)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,6 @@ public IEnumerator RepeatedClientDisconnectsNoop()
Assert.AreEqual(m_ServerEvents.Count, previousServerEventsCount);
Assert.AreEqual(m_ClientsEvents[0].Count, previousClientEventsCount);

m_Server.Shutdown();

yield return null;
}
}
Expand Down