Skip to content

Commit d40f04e

Browse files
chriscoolgitster
authored andcommitted
upload-pack: move static vars to upload_pack_data
As we cleanup 'upload-pack.c' by using 'struct upload_pack_data' more thoroughly, let's move the 'no_done', 'daemon_mode' and 'timeout' variables into this struct. They are only used by protocol v0 code since protocol v2 assumes certain baseline capabilities, but rolling them into upload_pack_data and just letting v2 code ignore them as it does now is more coherent and cleaner. Signed-off-by: Christian Couder <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a849728 commit d40f04e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

upload-pack.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
static timestamp_t oldest_have;
4646

4747
static int multi_ack;
48-
static int no_done;
49-
static int daemon_mode;
5048
/* Allow specifying sha1 if it is a ref tip. */
5149
#define ALLOW_TIP_SHA1 01
5250
/* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
@@ -56,7 +54,6 @@ static int daemon_mode;
5654
static unsigned int allow_unadvertised_object_request;
5755
static int shallow_nr;
5856
static struct object_array extra_edge_obj;
59-
static unsigned int timeout;
6057
static int keepalive = 5;
6158
/* 0 for no sideband,
6259
* otherwise maximum packet size (up to 65520 bytes).
@@ -88,11 +85,15 @@ struct upload_pack_data {
8885
int deepen_rev_list;
8986
int deepen_relative;
9087

88+
unsigned int timeout; /* v0 only */
89+
9190
struct list_objects_filter_options filter_options;
9291

9392
struct packet_writer writer;
9493

9594
unsigned stateless_rpc : 1; /* v0 only */
95+
unsigned no_done : 1; /* v0 only */
96+
unsigned daemon_mode : 1; /* v0 only */
9697

9798
unsigned use_thin_pack : 1;
9899
unsigned use_ofs_delta : 1;
@@ -135,7 +136,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
135136
list_objects_filter_release(&data->filter_options);
136137
}
137138

138-
static void reset_timeout(void)
139+
static void reset_timeout(unsigned int timeout)
139140
{
140141
alarm(timeout);
141142
}
@@ -251,7 +252,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
251252
int pe, pu, pollsize;
252253
int ret;
253254

254-
reset_timeout();
255+
reset_timeout(pack_data->timeout);
255256

256257
pollsize = 0;
257258
pe = pu = -1;
@@ -433,7 +434,7 @@ static int get_common_commits(struct upload_pack_data *data,
433434
for (;;) {
434435
const char *arg;
435436

436-
reset_timeout();
437+
reset_timeout(data->timeout);
437438

438439
if (packet_reader_read(reader) != PACKET_READ_NORMAL) {
439440
if (multi_ack == 2
@@ -446,7 +447,7 @@ static int get_common_commits(struct upload_pack_data *data,
446447
if (data->have_obj.nr == 0 || multi_ack)
447448
packet_write_fmt(1, "NAK\n");
448449

449-
if (no_done && sent_ready) {
450+
if (data->no_done && sent_ready) {
450451
packet_write_fmt(1, "ACK %s\n", last_hex);
451452
return 0;
452453
}
@@ -924,7 +925,7 @@ static void receive_needs(struct upload_pack_data *data,
924925
struct object_id oid_buf;
925926
const char *arg;
926927

927-
reset_timeout();
928+
reset_timeout(data->timeout);
928929
if (packet_reader_read(reader) != PACKET_READ_NORMAL)
929930
break;
930931

@@ -957,7 +958,7 @@ static void receive_needs(struct upload_pack_data *data,
957958
else if (parse_feature_request(features, "multi_ack"))
958959
multi_ack = 1;
959960
if (parse_feature_request(features, "no-done"))
960-
no_done = 1;
961+
data->no_done = 1;
961962
if (parse_feature_request(features, "thin-pack"))
962963
data->use_thin_pack = 1;
963964
if (parse_feature_request(features, "ofs-delta"))
@@ -1000,7 +1001,7 @@ static void receive_needs(struct upload_pack_data *data,
10001001
if (has_non_tip)
10011002
check_non_tip(data);
10021003

1003-
if (!use_sideband && daemon_mode)
1004+
if (!use_sideband && data->daemon_mode)
10041005
data->no_progress = 1;
10051006

10061007
if (data->depth == 0 && !data->deepen_rev_list && data->shallows.nr == 0)
@@ -1149,19 +1150,18 @@ void upload_pack(struct upload_pack_options *options)
11491150
struct packet_reader reader;
11501151
struct upload_pack_data data;
11511152

1152-
timeout = options->timeout;
1153-
daemon_mode = options->daemon_mode;
1154-
11551153
git_config(upload_pack_config, NULL);
11561154

11571155
upload_pack_data_init(&data);
11581156

11591157
data.stateless_rpc = options->stateless_rpc;
1158+
data.daemon_mode = options->daemon_mode;
1159+
data.timeout = options->timeout;
11601160

11611161
head_ref_namespaced(find_symref, &data.symref);
11621162

11631163
if (options->advertise_refs || !data.stateless_rpc) {
1164-
reset_timeout();
1164+
reset_timeout(data.timeout);
11651165
head_ref_namespaced(send_ref, &data);
11661166
for_each_namespaced_ref(send_ref, &data);
11671167
advertise_shallow_grafts(1);

0 commit comments

Comments
 (0)