socket-proxyd: fix off-by-one in connection limit

The limit is checked before the new connection is added to the set, so
with --connections-max=N and N connections open "set_size() > N" is
false and an additional connection is admitted. Use ">=" to refuse new
connections once the limit is reached.

(cherry picked from commit 9b51efd69fade39b0315251d02d1c9eab929891c)
This commit is contained in:
Kamil Monicz
2026-10-16 11:36:32 +01:00
committed by Luca Boccassi
parent bcf0a9ac58
commit f3d4d3e25a
3 changed files with 35 additions and 7 deletions
+1 -1
View File
@@ -409,7 +409,7 @@ static int context_add_connection(Context *context, int fd) {
log_debug("New connection from %s", strna(peer));
}
if (set_size(context->connections) > arg_connections_max)
if (set_size(context->connections) >= arg_connections_max)
return log_warning_errno(SYNTHETIC_ERRNO(EBUSY), "Hit connection limit, refusing connection.");
r = sd_event_source_set_enabled(context->idle_time, SD_EVENT_OFF);