Skip to content

Commit 7d200af

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8108d1a commit 7d200af

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

daemon.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#define USE_THE_REPOSITORY_VARIABLE
2-
#define DISABLE_SIGN_COMPARE_WARNINGS
32

43
#include "git-compat-util.h"
54
#include "abspath.h"
@@ -801,8 +800,7 @@ static int addrcmp(const struct sockaddr_storage *s1,
801800
return 0;
802801
}
803802

804-
static int max_connections = 32;
805-
803+
static unsigned int max_connections = 32;
806804
static unsigned int live_children;
807805

808806
static struct child {
@@ -1315,10 +1313,11 @@ int cmd_main(int argc, const char **argv)
13151313
continue;
13161314
}
13171315
if (skip_prefix(arg, "--max-connections=", &v)) {
1318-
if (strtol_i(v, 10, &max_connections))
1316+
int parsed_value;
1317+
if (strtol_i(v, 10, &parsed_value))
13191318
die(_("invalid max-connections '%s', expecting an integer"), v);
1320-
if (max_connections < 0)
1321-
max_connections = 0; /* unlimited */
1319+
/* A negative value indicates unlimited children. */
1320+
max_connections = parsed_value < 0 ? 0 : parsed_value;
13221321
continue;
13231322
}
13241323
if (!strcmp(arg, "--strict-paths")) {

0 commit comments

Comments
 (0)