From 072103823b42b07b55b94cb0ffc4febac3c348ad Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Mon, 8 Mar 2021 13:19:34 +0000 Subject: [PATCH] Increase maximum connection count on Windows from 2048 to 8192. This is only where supported. Closes #2122. Thanks to yellowgg2. --- ChangeLog.txt | 2 ++ src/mosquitto.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 69031fae..594d6d58 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,8 @@ Broker: - Add connection-state example plugin to demonstrate MOSQ_EVT_CONNECT. - Plugins on non-Windows platforms now no longer make their symbols globally available, which means they are self contained. +- Increase maximum connection count on Windows from 2048 to 8192 where + supported. Closes #2122. Client library: - Add MOSQ_OPT_DISABLE_SOCKETPAIR to allow the disabling of the socketpair diff --git a/src/mosquitto.c b/src/mosquitto.c index 53cd85f2..0fe8ba02 100644 --- a/src/mosquitto.c +++ b/src/mosquitto.c @@ -481,7 +481,13 @@ 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));