Skip to content
Open
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
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Change log

## [1.3.3] - 2023-03-17

### Fixes
* Fixed an issue where calling `ScheduleFlushSend` before the socket was bound would still result in socket system calls being made, resulting in errors being logged.

## [1.3.2] - 2023-03-09

### Fixes
* Fixed issue where UWP Xbox builds were crashing because the split buffer fix was not including UWP defines.
* Fixed an issue where `IPCNetworkInterface` would perform useless work for each packet received.
* Fixed an issue where `ReliableSequencedPipelineStage` could end up duplicating packets when sending reliable packets while the send queue is full.

## [1.3.1] - 2022-12-09

### Changes
* It is now possible to set a window size of up to 64 for `ReliableSequencedPipelineStage` (use `NetworkSettings.WithReliableStageParameters` to modify the value). Doing so increases the packet header size by 4 bytes though, so the default value remains at 32.

### Fixes
* Fixed an issue where if one end of a reliable pipeline stopped sending any traffic and its latest ACK message was lost, then the other end would stall.
* Fixed a crash when using DTLS if an update was delayed for long enough that both the disconnection and heartbeat timeouts expire.

## [1.3.0] - 2022-09-27

### New features
Expand Down
14 changes: 6 additions & 8 deletions Documentation~/filter.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# https://dotnet.github.io/docfx/tutorial/howto_filter_out_unwanted_apis_attributes.html

apiRules:
- exclude:
uidRegex: .*\.Tests.*
type: Namespace
type: Namespace
uidRegex: .*\.Tests.*
- exclude:
uidRegex: .*\.Editor$
type: Namespace
type: Namespace
uidRegex: .*\.Editor$
- exclude:
uidRegex: .*\.Samples$
type: Namespace
type: Namespace
uidRegex: .*\.Samples$
5 changes: 5 additions & 0 deletions Editor/RoslynAnalyzerFix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@

namespace Unity.Networking.Editor
{
/// <summary>Asset post-processor to fix loading of the Roslyn analyzer.</summary>
public class RoslynAnalyzerFix : AssetPostprocessor
{
private static readonly XNamespace xNamespace = "http://schemas.microsoft.com/developer/msbuild/2003";

/// <summary>Fix the inclusion of the Roslyn analyzer in CS project.</summary>
/// <param name="path">Path to the project file (unused).</param>
/// <param name="content">Content of the project file.</param>
/// <returns>New content of the project file.</returns>
public static string OnGeneratedCSProject(string path, string content)
{
// There is currently a bug in both VS Code Editor/Rider that doesn't properly resolve
Expand Down
6 changes: 3 additions & 3 deletions Runtime/BaselibNetworkArray.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#if UNITY_STANDALONE_WIN || UNITY_GAMECORE || UNITY_XBOXONE || UNITY_EDITOR_WIN
#define BASELIB_USE_SPLIT_BUFFERS
#if UNITY_STANDALONE_WIN || UNITY_GAMECORE || UNITY_XBOXONE || UNITY_EDITOR_WIN || UNITY_WSA || UNITY_WSA_10_0
#define BASELIB_USE_SPLIT_BUFFERS
#else
#undef BASELIB_USE_SPLIT_BUFFERS
#undef BASELIB_USE_SPLIT_BUFFERS
#endif

using System;
Expand Down
19 changes: 16 additions & 3 deletions Runtime/BaselibNetworkInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Unity.Networking.Transport
using NetworkEndpoint = Binding.Baselib_RegisteredNetwork_Endpoint;
using NetworkSocket = Binding.Baselib_RegisteredNetwork_Socket_UDP;

/// <summary>Extensions for <see cref="BaselibNetworkParameter"/>.</summary>
public static class BaselibNetworkParameterExtensions
{
internal const int k_defaultRxQueueSize = 64;
Expand All @@ -28,9 +29,11 @@ public static class BaselibNetworkParameterExtensions
/// <summary>
/// Sets the <see cref="BaselibNetworkParameter"/> values for the <see cref="NetworkSettings"/>
/// </summary>
/// <param name="settings"><see cref="NetworkSettings"/> to modify.</param>
/// <param name="receiveQueueCapacity"><seealso cref="BaselibNetworkParameter.receiveQueueCapacity"/></param>
/// <param name="sendQueueCapacity"><seealso cref="BaselibNetworkParameter.sendQueueCapacity"/></param>
/// <param name="maximumPayloadSize"><seealso cref="BaselibNetworkParameter.maximumPayloadSize"/></param>
/// <returns>Modified <see cref="NetworkSettings"/>.</returns>
public static ref NetworkSettings WithBaselibNetworkInterfaceParameters(
ref this NetworkSettings settings,
int receiveQueueCapacity = k_defaultRxQueueSize,
Expand All @@ -53,6 +56,7 @@ public static ref NetworkSettings WithBaselibNetworkInterfaceParameters(
/// <summary>
/// Gets the <see cref="BaselibNetworkParameter"/>
/// </summary>
/// <param name="settings"><see cref="NetworkSettings"/> to get parameters from.</param>
/// <returns>Returns the <see cref="BaselibNetworkParameter"/> values for the <see cref="NetworkSettings"/></returns>
public static BaselibNetworkParameter GetBaselibNetworkInterfaceParameters(ref this NetworkSettings settings)
{
Expand Down Expand Up @@ -85,6 +89,8 @@ public struct BaselibNetworkParameter : INetworkParameter
/// </summary>
public uint maximumPayloadSize;

/// <summary>Validate the settings.</summary>
/// <returns>True if the settings are valid, false otherwise.</returns>
public bool Validate()
{
var valid = true;
Expand Down Expand Up @@ -253,6 +259,7 @@ internal unsafe struct BaselibData
/// Converts a generic <see cref="NetworkEndPoint"/> to its <see cref="NetworkInterfaceEndPoint"/> version for the <see cref="BaselibNetworkInterface"/>.
/// </summary>
/// <param name="address">The <see cref="NetworkEndPoint"/> endpoint to convert.</param>
/// <param name="endpoint">The new <see cref="NetworkInterfaceEndPoint"/>.</param>
/// <returns>returns 0 on success and sets the converted endpoint value</returns>
public unsafe int CreateInterfaceEndPoint(NetworkEndPoint address, out NetworkInterfaceEndPoint endpoint)
{
Expand Down Expand Up @@ -318,8 +325,8 @@ public unsafe NetworkEndPoint GetGenericEndPoint(NetworkInterfaceEndPoint endpoi
/// <summary>
/// Initializes a instance of the <see cref="BaselibNetworkInterface"/> struct.
/// </summary>
/// <param name="param">An array of INetworkParameter. If there is no <see cref="BaselibNetworkParameter"/> present, the default values are used.</param>
/// <returns>Returns 0 on succees.</returns>
/// <param name="settings"><see cref="NetworkSettings"/> with which to configure the interface.</param>
/// <returns>Returns 0 on success.</returns>
public unsafe int Initialize(NetworkSettings settings)
{
configuration = settings.GetBaselibNetworkInterfaceParameters();
Expand Down Expand Up @@ -617,7 +624,12 @@ public unsafe int Bind(NetworkInterfaceEndPoint endpoint)
checked((uint)configuration.receiveQueueCapacity),
&error);
if (error.code != ErrorCode.Success)
{
if (error.code == ErrorCode.AddressInUse)
UnityEngine.Debug.LogError("Failed to bind the socket because address is already in use. " +
"It is likely that another process is already listening on the same port.");
return (int)error.code == -1 ? (int)Error.StatusCode.NetworkSocketError : -(int)error.code;
}

// Close old socket now that new one has been successfully created.
if (m_Baselib[0].m_Socket.handle != IntPtr.Zero)
Expand Down Expand Up @@ -709,6 +721,7 @@ private static unsafe int BeginSendMessage(out NetworkInterfaceSendHandle handle
var baselib = (BaselibData*)userData;
handle = default;
int index = baselib->m_PayloadsTx.AcquireHandle();

if (index < 0)
return (int)Error.StatusCode.NetworkSendQueueFull;

Expand Down Expand Up @@ -747,7 +760,7 @@ private static unsafe int EndSendMessage(ref NetworkInterfaceSendHandle handle,
messagePtr,
1u,
&error);
if (error.code != ErrorCode.Success)
if (error.code != ErrorCode.Success || count != 1u)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is part of the fix. The low level Linux UDP networking code wasn't properly signaling an error (didn't end up being our issue but is a legit bug, Simon said).

{
baselib->m_PayloadsTx.ReleaseHandle(index);
return (int)error.code == -1 ? -1 : -(int)error.code;
Expand Down
Loading