Skip to content

Commit eea7f7a

Browse files
avargitster
authored andcommitted
serve: move transfer.advertiseSID check into session_id_advertise()
In 6b5b6e4 (serve: advertise session ID in v2 capabilities, 2020-11-11) the check for transfer.advertiseSID was added to the beginning of the main serve() loop. Thus on startup of the server we'd populate it. Let's instead use an explicit lazy initialization pattern in session_id_advertise() itself, we'll still look the config up only once per-process, but by moving it out of serve() itself the further changing of that routine becomes easier. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 28a592e commit eea7f7a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

serve.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "serve.h"
1010
#include "upload-pack.h"
1111

12-
static int advertise_sid;
12+
static int advertise_sid = -1;
1313

1414
static int always_advertise(struct repository *r,
1515
struct strbuf *value)
@@ -35,6 +35,9 @@ static int object_format_advertise(struct repository *r,
3535

3636
static int session_id_advertise(struct repository *r, struct strbuf *value)
3737
{
38+
if (advertise_sid == -1 &&
39+
git_config_get_bool("transfer.advertisesid", &advertise_sid))
40+
advertise_sid = 0;
3841
if (!advertise_sid)
3942
return 0;
4043
if (value)
@@ -300,8 +303,6 @@ static int process_request(void)
300303
/* Main serve loop for protocol version 2 */
301304
void serve(struct serve_options *options)
302305
{
303-
git_config_get_bool("transfer.advertisesid", &advertise_sid);
304-
305306
if (options->advertise_capabilities || !options->stateless_rpc) {
306307
/* serve by default supports v2 */
307308
packet_write_fmt(1, "version 2\n");

0 commit comments

Comments
 (0)