From 3b2f3c6d8a5b361c89e4fcc3ccebe126dc9a45f9 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Fri, 7 Apr 2023 19:29:13 +0100 Subject: [PATCH] Windows: Increase connection limit to 8192 where supported. Closes #2732. Thanks to zhousongsong. --- ChangeLog.txt | 2 ++ src/mosquitto.c | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 11c0972b..75a03b18 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,8 @@ Broker: assertions removed. Closes #2708. - Fix default settings incorrectly allowing TLS v1.1. Closes #2722. - Use line buffered mode for stdout. Closes #2354. Closes #2749. +- Fix connections being limited to 2048 on Windows. The limit is now 8192, + where supported. Closes #2732. Client library: - Use CLOCK_BOOTTIME when available, to keep track of time. This solves the diff --git a/src/mosquitto.c b/src/mosquitto.c index 4dfd2bde..431254d8 100644 --- a/src/mosquitto.c +++ b/src/mosquitto.c @@ -484,7 +484,12 @@ int main(int argc, char *argv[]) #endif #ifdef WIN32 - _setmaxstdio(2048); + if(_setmaxstdio(8192) != 8192){ + /* Old limit was 2048 */ + if(_setmaxstdio(2048) != 2048){ + log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Unable to increase maximum allowed connections. This session may be limited to 512 connections."); + } + } #endif memset(&db, 0, sizeof(struct mosquitto_db));