aboutsummaryrefslogtreecommitdiffstats
path: root/daemon.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-12-06 11:27:26 +0100
committerJunio C Hamano <gitster@pobox.com>2024-12-06 20:20:04 +0900
commit7d200af27f41b8732dcb1a6c01ff73b7b7b0ecc1 (patch)
tree31807df4e6ea90a215f7226441072d862f2b7161 /daemon.c
parentdaemon: fix loops that have mismatching integer types (diff)
downloadgit-7d200af27f41b8732dcb1a6c01ff73b7b7b0ecc1.tar.gz
git-7d200af27f41b8732dcb1a6c01ff73b7b7b0ecc1.zip
daemon: fix type of `max_connections`
The `max_connections` type tracks how many children git-daemon(1) would spawn at the same time. This value can be controlled via a command line switch: if given a positive value we'll set that up as the limit. But when given either zero or a negative value we don't enforce any limit at all. But even when being passed a negative value we won't actually store it, but normalize it to 0. Still, the variable used to store the config is using a signed integer, which causes warnings when comparing the number of accepted connections (`max_connections`) with the number of current connections being handled (`live_children`). Adapt the type of `max_connections` such that the types of both variables match. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'daemon.c')
-rw-r--r--daemon.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/daemon.c b/daemon.c
index bf313bc21a..5ca70335fc 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,5 +1,4 @@
#define USE_THE_REPOSITORY_VARIABLE
-#define DISABLE_SIGN_COMPARE_WARNINGS
#include "git-compat-util.h"
#include "abspath.h"
@@ -801,8 +800,7 @@ static int addrcmp(const struct sockaddr_storage *s1,
return 0;
}
-static int max_connections = 32;
-
+static unsigned int max_connections = 32;
static unsigned int live_children;
static struct child {
@@ -1315,10 +1313,11 @@ int cmd_main(int argc, const char **argv)
continue;
}
if (skip_prefix(arg, "--max-connections=", &v)) {
- if (strtol_i(v, 10, &max_connections))
+ int parsed_value;
+ if (strtol_i(v, 10, &parsed_value))
die(_("invalid max-connections '%s', expecting an integer"), v);
- if (max_connections < 0)
- max_connections = 0; /* unlimited */
+ /* A negative value indicates unlimited children. */
+ max_connections = parsed_value < 0 ? 0 : parsed_value;
continue;
}
if (!strcmp(arg, "--strict-paths")) {