45
45
static timestamp_t oldest_have ;
46
46
47
47
static int multi_ack ;
48
- static int no_done ;
49
- static int daemon_mode ;
50
48
/* Allow specifying sha1 if it is a ref tip. */
51
49
#define ALLOW_TIP_SHA1 01
52
50
/* Allow request of a sha1 if it is reachable from a ref (possibly hidden ref). */
@@ -56,7 +54,6 @@ static int daemon_mode;
56
54
static unsigned int allow_unadvertised_object_request ;
57
55
static int shallow_nr ;
58
56
static struct object_array extra_edge_obj ;
59
- static unsigned int timeout ;
60
57
static int keepalive = 5 ;
61
58
/* 0 for no sideband,
62
59
* otherwise maximum packet size (up to 65520 bytes).
@@ -88,11 +85,15 @@ struct upload_pack_data {
88
85
int deepen_rev_list ;
89
86
int deepen_relative ;
90
87
88
+ unsigned int timeout ; /* v0 only */
89
+
91
90
struct list_objects_filter_options filter_options ;
92
91
93
92
struct packet_writer writer ;
94
93
95
94
unsigned stateless_rpc : 1 ; /* v0 only */
95
+ unsigned no_done : 1 ; /* v0 only */
96
+ unsigned daemon_mode : 1 ; /* v0 only */
96
97
97
98
unsigned use_thin_pack : 1 ;
98
99
unsigned use_ofs_delta : 1 ;
@@ -135,7 +136,7 @@ static void upload_pack_data_clear(struct upload_pack_data *data)
135
136
list_objects_filter_release (& data -> filter_options );
136
137
}
137
138
138
- static void reset_timeout (void )
139
+ static void reset_timeout (unsigned int timeout )
139
140
{
140
141
alarm (timeout );
141
142
}
@@ -251,7 +252,7 @@ static void create_pack_file(struct upload_pack_data *pack_data)
251
252
int pe , pu , pollsize ;
252
253
int ret ;
253
254
254
- reset_timeout ();
255
+ reset_timeout (pack_data -> timeout );
255
256
256
257
pollsize = 0 ;
257
258
pe = pu = -1 ;
@@ -433,7 +434,7 @@ static int get_common_commits(struct upload_pack_data *data,
433
434
for (;;) {
434
435
const char * arg ;
435
436
436
- reset_timeout ();
437
+ reset_timeout (data -> timeout );
437
438
438
439
if (packet_reader_read (reader ) != PACKET_READ_NORMAL ) {
439
440
if (multi_ack == 2
@@ -446,7 +447,7 @@ static int get_common_commits(struct upload_pack_data *data,
446
447
if (data -> have_obj .nr == 0 || multi_ack )
447
448
packet_write_fmt (1 , "NAK\n" );
448
449
449
- if (no_done && sent_ready ) {
450
+ if (data -> no_done && sent_ready ) {
450
451
packet_write_fmt (1 , "ACK %s\n" , last_hex );
451
452
return 0 ;
452
453
}
@@ -924,7 +925,7 @@ static void receive_needs(struct upload_pack_data *data,
924
925
struct object_id oid_buf ;
925
926
const char * arg ;
926
927
927
- reset_timeout ();
928
+ reset_timeout (data -> timeout );
928
929
if (packet_reader_read (reader ) != PACKET_READ_NORMAL )
929
930
break ;
930
931
@@ -957,7 +958,7 @@ static void receive_needs(struct upload_pack_data *data,
957
958
else if (parse_feature_request (features , "multi_ack" ))
958
959
multi_ack = 1 ;
959
960
if (parse_feature_request (features , "no-done" ))
960
- no_done = 1 ;
961
+ data -> no_done = 1 ;
961
962
if (parse_feature_request (features , "thin-pack" ))
962
963
data -> use_thin_pack = 1 ;
963
964
if (parse_feature_request (features , "ofs-delta" ))
@@ -1000,7 +1001,7 @@ static void receive_needs(struct upload_pack_data *data,
1000
1001
if (has_non_tip )
1001
1002
check_non_tip (data );
1002
1003
1003
- if (!use_sideband && daemon_mode )
1004
+ if (!use_sideband && data -> daemon_mode )
1004
1005
data -> no_progress = 1 ;
1005
1006
1006
1007
if (data -> depth == 0 && !data -> deepen_rev_list && data -> shallows .nr == 0 )
@@ -1149,19 +1150,18 @@ void upload_pack(struct upload_pack_options *options)
1149
1150
struct packet_reader reader ;
1150
1151
struct upload_pack_data data ;
1151
1152
1152
- timeout = options -> timeout ;
1153
- daemon_mode = options -> daemon_mode ;
1154
-
1155
1153
git_config (upload_pack_config , NULL );
1156
1154
1157
1155
upload_pack_data_init (& data );
1158
1156
1159
1157
data .stateless_rpc = options -> stateless_rpc ;
1158
+ data .daemon_mode = options -> daemon_mode ;
1159
+ data .timeout = options -> timeout ;
1160
1160
1161
1161
head_ref_namespaced (find_symref , & data .symref );
1162
1162
1163
1163
if (options -> advertise_refs || !data .stateless_rpc ) {
1164
- reset_timeout ();
1164
+ reset_timeout (data . timeout );
1165
1165
head_ref_namespaced (send_ref , & data );
1166
1166
for_each_namespaced_ref (send_ref , & data );
1167
1167
advertise_shallow_grafts (1 );
0 commit comments