Skip to content

Commit

Permalink
Address Issue #80 packetInbox/packetOutbox may already be destroyed b…
Browse files Browse the repository at this point in the history
…efore NetworkManager.Shutdown() is called. The very obvious fragility of the code is an issue, but we'll slap a bandaid on there.
  • Loading branch information
cinderblocks committed Jun 30, 2024
1 parent 714f7bf commit def5ea1
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions LibreMetaverse/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,16 +559,16 @@ public Simulator Connect(IPAddress ip, ushort port, ulong handle, bool setDefaul
return Connect(endPoint, handle, setDefault, seedcaps, sizeX, sizeY);
}

/// <summary>
/// Connect to simulator assuming legacy region size
/// </summary>
/// <param name="endPoint"></param>
/// <param name="handle"></param>
/// <param name="setDefault"></param>
/// <param name="seedcaps"></param>
/// <returns></returns>
public Simulator Connect(IPEndPoint endPoint, ulong handle, bool setDefault, Uri seedcaps) {
return Connect(endPoint, handle, setDefault, seedcaps, Simulator.DefaultRegionSizeX, Simulator.DefaultRegionSizeY);
/// <summary>
/// Connect to simulator assuming legacy region size
/// </summary>
/// <param name="endPoint"></param>
/// <param name="handle"></param>
/// <param name="setDefault"></param>
/// <param name="seedcaps"></param>
/// <returns></returns>
public Simulator Connect(IPEndPoint endPoint, ulong handle, bool setDefault, Uri seedcaps) {
return Connect(endPoint, handle, setDefault, seedcaps, Simulator.DefaultRegionSizeX, Simulator.DefaultRegionSizeY);
}
/// <summary>
/// Connect to a simulator
Expand Down Expand Up @@ -892,10 +892,14 @@ public void Shutdown(DisconnectType type, string message)
OnSimDisconnected(new SimDisconnectedEventArgs(CurrentSim, type));
}
}

_packetInbox.Writer.Complete();
_packetOutbox.Writer.Complete();

try
{
_packetInbox.Writer.Complete();
_packetOutbox.Writer.Complete();
}
catch (NullReferenceException)
{ /* noop! */ }
_packetInbox = null;
_packetOutbox = null;

Expand Down

0 comments on commit def5ea1

Please sign in to comment.