From 651caeba91ed020cdebb5a6b1335c4e37ee66557 Mon Sep 17 00:00:00 2001 From: Jack <40802798+Jack073@users.noreply.github.com> Date: Sun, 31 Oct 2021 21:01:22 +0000 Subject: [PATCH] Fix build for Windows (#1377) (#1506) * Fix build for Windows (#1377) * Add tests for windows --- .github/workflows/test.yaml | 2 +- core/chat/concurrentConnections.go | 3 ++- core/chat/concurrentConnections_windows.go | 6 ++++++ core/chat/utils.go | 3 +++ core/chat/utils_windows.go | 12 ++++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 core/chat/concurrentConnections_windows.go create mode 100644 core/chat/utils_windows.go diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cdd661626..e0f1dc8b5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -6,7 +6,7 @@ jobs: strategy: matrix: go-version: [1.15.x, 1.16.x] - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v2 diff --git a/core/chat/concurrentConnections.go b/core/chat/concurrentConnections.go index 0a968b549..cbbea81c3 100644 --- a/core/chat/concurrentConnections.go +++ b/core/chat/concurrentConnections.go @@ -1,5 +1,6 @@ // nolint:goimports -// +build !freebsd +//go:build !freebsd && !windows +// +build !freebsd,!windows package chat diff --git a/core/chat/concurrentConnections_windows.go b/core/chat/concurrentConnections_windows.go new file mode 100644 index 000000000..ef61843b3 --- /dev/null +++ b/core/chat/concurrentConnections_windows.go @@ -0,0 +1,6 @@ +//go:build windows +// +build windows + +package chat + +func setSystemConcurrentConnectionLimit(limit int64) {} diff --git a/core/chat/utils.go b/core/chat/utils.go index 7ab6efea7..fae7beb29 100644 --- a/core/chat/utils.go +++ b/core/chat/utils.go @@ -1,3 +1,6 @@ +//go:build !windows +// +build !windows + package chat import ( diff --git a/core/chat/utils_windows.go b/core/chat/utils_windows.go new file mode 100644 index 000000000..56fd59854 --- /dev/null +++ b/core/chat/utils_windows.go @@ -0,0 +1,12 @@ +//go:build windows +// +build windows + +package chat + +func getMaximumConcurrentConnectionLimit() int64 { + // The maximum limit I can find for windows is 16,777,216 + // (essentially unlimited, but add the 0.7 multiplier as well to be + // consistent with other systems) + // https://docs.microsoft.com/en-gb/archive/blogs/markrussinovich/pushing-the-limits-of-windows-handles + return (16777216 * 7) / 10 +}