@@ -302,6 +302,7 @@ static void start_move(struct transfer_request *request)
302
302
static int refresh_lock (struct remote_lock * check_lock )
303
303
{
304
304
struct active_request_slot * slot ;
305
+ struct slot_results results ;
305
306
char * if_header ;
306
307
char timeout_header [25 ];
307
308
struct curl_slist * dav_headers = NULL ;
@@ -329,6 +330,7 @@ static int refresh_lock(struct remote_lock *check_lock)
329
330
dav_headers = curl_slist_append (dav_headers , timeout_header );
330
331
331
332
slot = get_active_slot ();
333
+ slot -> results = & results ;
332
334
curl_easy_setopt (slot -> curl , CURLOPT_HTTPGET , 1 );
333
335
curl_easy_setopt (slot -> curl , CURLOPT_WRITEFUNCTION , fwrite_null );
334
336
curl_easy_setopt (slot -> curl , CURLOPT_URL , lock -> url );
@@ -337,8 +339,8 @@ static int refresh_lock(struct remote_lock *check_lock)
337
339
338
340
if (start_active_slot (slot )) {
339
341
run_active_slot (slot );
340
- if (slot -> curl_result != CURLE_OK ) {
341
- fprintf (stderr , "Got HTTP error %ld\n" , slot -> http_code );
342
+ if (results . curl_result != CURLE_OK ) {
343
+ fprintf (stderr , "Got HTTP error %ld\n" , results . http_code );
342
344
lock -> active = 0 ;
343
345
} else {
344
346
lock -> active = 1 ;
@@ -509,16 +511,18 @@ static int fetch_index(unsigned char *sha1)
509
511
510
512
FILE * indexfile ;
511
513
struct active_request_slot * slot ;
514
+ struct slot_results results ;
512
515
513
516
/* Don't use the index if the pack isn't there */
514
517
url = xmalloc (strlen (remote -> url ) + 65 );
515
518
sprintf (url , "%s/objects/pack/pack-%s.pack" , remote -> url , hex );
516
519
slot = get_active_slot ();
520
+ slot -> results = & results ;
517
521
curl_easy_setopt (slot -> curl , CURLOPT_URL , url );
518
522
curl_easy_setopt (slot -> curl , CURLOPT_NOBODY , 1 );
519
523
if (start_active_slot (slot )) {
520
524
run_active_slot (slot );
521
- if (slot -> curl_result != CURLE_OK ) {
525
+ if (results . curl_result != CURLE_OK ) {
522
526
free (url );
523
527
return error ("Unable to verify pack %s is available" ,
524
528
hex );
@@ -543,6 +547,7 @@ static int fetch_index(unsigned char *sha1)
543
547
filename );
544
548
545
549
slot = get_active_slot ();
550
+ slot -> results = & results ;
546
551
curl_easy_setopt (slot -> curl , CURLOPT_NOBODY , 0 );
547
552
curl_easy_setopt (slot -> curl , CURLOPT_HTTPGET , 1 );
548
553
curl_easy_setopt (slot -> curl , CURLOPT_FILE , indexfile );
@@ -566,7 +571,7 @@ static int fetch_index(unsigned char *sha1)
566
571
567
572
if (start_active_slot (slot )) {
568
573
run_active_slot (slot );
569
- if (slot -> curl_result != CURLE_OK ) {
574
+ if (results . curl_result != CURLE_OK ) {
570
575
free (url );
571
576
fclose (indexfile );
572
577
return error ("Unable to get pack index %s\n%s" , url ,
@@ -606,6 +611,7 @@ static int fetch_indices(void)
606
611
int i = 0 ;
607
612
608
613
struct active_request_slot * slot ;
614
+ struct slot_results results ;
609
615
610
616
data = xmalloc (4096 );
611
617
memset (data , 0 , 4096 );
@@ -620,16 +626,17 @@ static int fetch_indices(void)
620
626
sprintf (url , "%s/objects/info/packs" , remote -> url );
621
627
622
628
slot = get_active_slot ();
629
+ slot -> results = & results ;
623
630
curl_easy_setopt (slot -> curl , CURLOPT_FILE , & buffer );
624
631
curl_easy_setopt (slot -> curl , CURLOPT_WRITEFUNCTION , fwrite_buffer );
625
632
curl_easy_setopt (slot -> curl , CURLOPT_URL , url );
626
633
curl_easy_setopt (slot -> curl , CURLOPT_HTTPHEADER , NULL );
627
634
if (start_active_slot (slot )) {
628
635
run_active_slot (slot );
629
- if (slot -> curl_result != CURLE_OK ) {
636
+ if (results . curl_result != CURLE_OK ) {
630
637
free (buffer .buffer );
631
638
free (url );
632
- if (slot -> http_code == 404 )
639
+ if (results . http_code == 404 )
633
640
return 0 ;
634
641
else
635
642
return error ("%s" , curl_errorstr );
@@ -716,20 +723,22 @@ int fetch_ref(char *ref, unsigned char *sha1)
716
723
struct buffer buffer ;
717
724
char * base = remote -> url ;
718
725
struct active_request_slot * slot ;
726
+ struct slot_results results ;
719
727
buffer .size = 41 ;
720
728
buffer .posn = 0 ;
721
729
buffer .buffer = hex ;
722
730
hex [41 ] = '\0' ;
723
-
731
+
724
732
url = quote_ref_url (base , ref );
725
733
slot = get_active_slot ();
734
+ slot -> results = & results ;
726
735
curl_easy_setopt (slot -> curl , CURLOPT_FILE , & buffer );
727
736
curl_easy_setopt (slot -> curl , CURLOPT_WRITEFUNCTION , fwrite_buffer );
728
737
curl_easy_setopt (slot -> curl , CURLOPT_HTTPHEADER , NULL );
729
738
curl_easy_setopt (slot -> curl , CURLOPT_URL , url );
730
739
if (start_active_slot (slot )) {
731
740
run_active_slot (slot );
732
- if (slot -> curl_result != CURLE_OK )
741
+ if (results . curl_result != CURLE_OK )
733
742
return error ("Couldn't get %s for %s\n%s" ,
734
743
url , ref , curl_errorstr );
735
744
} else {
@@ -913,6 +922,7 @@ xml_cdata(void *userData, const XML_Char *s, int len)
913
922
static struct remote_lock * lock_remote (char * path , long timeout )
914
923
{
915
924
struct active_request_slot * slot ;
925
+ struct slot_results results ;
916
926
struct buffer out_buffer ;
917
927
struct buffer in_buffer ;
918
928
char * out_data ;
@@ -946,14 +956,15 @@ static struct remote_lock *lock_remote(char *path, long timeout)
946
956
while (ep ) {
947
957
* ep = 0 ;
948
958
slot = get_active_slot ();
959
+ slot -> results = & results ;
949
960
curl_easy_setopt (slot -> curl , CURLOPT_HTTPGET , 1 );
950
961
curl_easy_setopt (slot -> curl , CURLOPT_URL , url );
951
962
curl_easy_setopt (slot -> curl , CURLOPT_CUSTOMREQUEST , DAV_MKCOL );
952
963
curl_easy_setopt (slot -> curl , CURLOPT_WRITEFUNCTION , fwrite_null );
953
964
if (start_active_slot (slot )) {
954
965
run_active_slot (slot );
955
- if (slot -> curl_result != CURLE_OK &&
956
- slot -> http_code != 405 ) {
966
+ if (results . curl_result != CURLE_OK &&
967
+ results . http_code != 405 ) {
957
968
fprintf (stderr ,
958
969
"Unable to create branch path %s\n" ,
959
970
url );
@@ -985,6 +996,7 @@ static struct remote_lock *lock_remote(char *path, long timeout)
985
996
dav_headers = curl_slist_append (dav_headers , "Content-Type: text/xml" );
986
997
987
998
slot = get_active_slot ();
999
+ slot -> results = & results ;
988
1000
curl_easy_setopt (slot -> curl , CURLOPT_INFILE , & out_buffer );
989
1001
curl_easy_setopt (slot -> curl , CURLOPT_INFILESIZE , out_buffer .size );
990
1002
curl_easy_setopt (slot -> curl , CURLOPT_READFUNCTION , fread_buffer );
@@ -1003,7 +1015,7 @@ static struct remote_lock *lock_remote(char *path, long timeout)
1003
1015
1004
1016
if (start_active_slot (slot )) {
1005
1017
run_active_slot (slot );
1006
- if (slot -> curl_result == CURLE_OK ) {
1018
+ if (results . curl_result == CURLE_OK ) {
1007
1019
ctx .name = xcalloc (10 , 1 );
1008
1020
ctx .len = 0 ;
1009
1021
ctx .cdata = NULL ;
@@ -1053,6 +1065,7 @@ static struct remote_lock *lock_remote(char *path, long timeout)
1053
1065
static int unlock_remote (struct remote_lock * lock )
1054
1066
{
1055
1067
struct active_request_slot * slot ;
1068
+ struct slot_results results ;
1056
1069
char * lock_token_header ;
1057
1070
struct curl_slist * dav_headers = NULL ;
1058
1071
int rc = 0 ;
@@ -1063,18 +1076,19 @@ static int unlock_remote(struct remote_lock *lock)
1063
1076
dav_headers = curl_slist_append (dav_headers , lock_token_header );
1064
1077
1065
1078
slot = get_active_slot ();
1079
+ slot -> results = & results ;
1066
1080
curl_easy_setopt (slot -> curl , CURLOPT_WRITEFUNCTION , fwrite_null );
1067
1081
curl_easy_setopt (slot -> curl , CURLOPT_URL , lock -> url );
1068
1082
curl_easy_setopt (slot -> curl , CURLOPT_CUSTOMREQUEST , DAV_UNLOCK );
1069
1083
curl_easy_setopt (slot -> curl , CURLOPT_HTTPHEADER , dav_headers );
1070
1084
1071
1085
if (start_active_slot (slot )) {
1072
1086
run_active_slot (slot );
1073
- if (slot -> curl_result == CURLE_OK )
1087
+ if (results . curl_result == CURLE_OK )
1074
1088
rc = 1 ;
1075
1089
else
1076
1090
fprintf (stderr , "Got HTTP error %ld\n" ,
1077
- slot -> http_code );
1091
+ results . http_code );
1078
1092
} else {
1079
1093
fprintf (stderr , "Unable to start request\n" );
1080
1094
}
@@ -1091,6 +1105,7 @@ static void crawl_remote_refs(char *path)
1091
1105
{
1092
1106
char * url ;
1093
1107
struct active_request_slot * slot ;
1108
+ struct slot_results results ;
1094
1109
struct buffer in_buffer ;
1095
1110
struct buffer out_buffer ;
1096
1111
char * in_data ;
@@ -1125,6 +1140,7 @@ static void crawl_remote_refs(char *path)
1125
1140
dav_headers = curl_slist_append (dav_headers , "Content-Type: text/xml" );
1126
1141
1127
1142
slot = get_active_slot ();
1143
+ slot -> results = & results ;
1128
1144
curl_easy_setopt (slot -> curl , CURLOPT_INFILE , & out_buffer );
1129
1145
curl_easy_setopt (slot -> curl , CURLOPT_INFILESIZE , out_buffer .size );
1130
1146
curl_easy_setopt (slot -> curl , CURLOPT_READFUNCTION , fread_buffer );
@@ -1137,7 +1153,7 @@ static void crawl_remote_refs(char *path)
1137
1153
1138
1154
if (start_active_slot (slot )) {
1139
1155
run_active_slot (slot );
1140
- if (slot -> curl_result == CURLE_OK ) {
1156
+ if (results . curl_result == CURLE_OK ) {
1141
1157
ctx .name = xcalloc (10 , 1 );
1142
1158
ctx .len = 0 ;
1143
1159
ctx .cdata = NULL ;
@@ -1171,6 +1187,7 @@ static void get_remote_object_list(unsigned char parent)
1171
1187
{
1172
1188
char * url ;
1173
1189
struct active_request_slot * slot ;
1190
+ struct slot_results results ;
1174
1191
struct buffer in_buffer ;
1175
1192
struct buffer out_buffer ;
1176
1193
char * in_data ;
@@ -1203,6 +1220,7 @@ static void get_remote_object_list(unsigned char parent)
1203
1220
dav_headers = curl_slist_append (dav_headers , "Content-Type: text/xml" );
1204
1221
1205
1222
slot = get_active_slot ();
1223
+ slot -> results = & results ;
1206
1224
curl_easy_setopt (slot -> curl , CURLOPT_INFILE , & out_buffer );
1207
1225
curl_easy_setopt (slot -> curl , CURLOPT_INFILESIZE , out_buffer .size );
1208
1226
curl_easy_setopt (slot -> curl , CURLOPT_READFUNCTION , fread_buffer );
@@ -1215,7 +1233,7 @@ static void get_remote_object_list(unsigned char parent)
1215
1233
1216
1234
if (start_active_slot (slot )) {
1217
1235
run_active_slot (slot );
1218
- if (slot -> curl_result == CURLE_OK ) {
1236
+ if (results . curl_result == CURLE_OK ) {
1219
1237
remote_dir_exists [parent ] = 1 ;
1220
1238
ctx .name = xcalloc (10 , 1 );
1221
1239
ctx .len = 0 ;
@@ -1250,6 +1268,7 @@ static void get_remote_object_list(unsigned char parent)
1250
1268
static int locking_available (void )
1251
1269
{
1252
1270
struct active_request_slot * slot ;
1271
+ struct slot_results results ;
1253
1272
struct buffer in_buffer ;
1254
1273
struct buffer out_buffer ;
1255
1274
char * in_data ;
@@ -1276,8 +1295,9 @@ static int locking_available(void)
1276
1295
1277
1296
dav_headers = curl_slist_append (dav_headers , "Depth: 0" );
1278
1297
dav_headers = curl_slist_append (dav_headers , "Content-Type: text/xml" );
1279
-
1298
+
1280
1299
slot = get_active_slot ();
1300
+ slot -> results = & results ;
1281
1301
curl_easy_setopt (slot -> curl , CURLOPT_INFILE , & out_buffer );
1282
1302
curl_easy_setopt (slot -> curl , CURLOPT_INFILESIZE , out_buffer .size );
1283
1303
curl_easy_setopt (slot -> curl , CURLOPT_READFUNCTION , fread_buffer );
@@ -1290,7 +1310,7 @@ static int locking_available(void)
1290
1310
1291
1311
if (start_active_slot (slot )) {
1292
1312
run_active_slot (slot );
1293
- if (slot -> curl_result == CURLE_OK ) {
1313
+ if (results . curl_result == CURLE_OK ) {
1294
1314
ctx .name = xcalloc (10 , 1 );
1295
1315
ctx .len = 0 ;
1296
1316
ctx .cdata = NULL ;
@@ -1416,6 +1436,7 @@ static void get_delta(struct rev_info *revs, struct remote_lock *lock)
1416
1436
static int update_remote (unsigned char * sha1 , struct remote_lock * lock )
1417
1437
{
1418
1438
struct active_request_slot * slot ;
1439
+ struct slot_results results ;
1419
1440
char * out_data ;
1420
1441
char * if_header ;
1421
1442
struct buffer out_buffer ;
@@ -1437,6 +1458,7 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock)
1437
1458
out_buffer .buffer = out_data ;
1438
1459
1439
1460
slot = get_active_slot ();
1461
+ slot -> results = & results ;
1440
1462
curl_easy_setopt (slot -> curl , CURLOPT_INFILE , & out_buffer );
1441
1463
curl_easy_setopt (slot -> curl , CURLOPT_INFILESIZE , out_buffer .size );
1442
1464
curl_easy_setopt (slot -> curl , CURLOPT_READFUNCTION , fread_buffer );
@@ -1451,10 +1473,10 @@ static int update_remote(unsigned char *sha1, struct remote_lock *lock)
1451
1473
run_active_slot (slot );
1452
1474
free (out_data );
1453
1475
free (if_header );
1454
- if (slot -> curl_result != CURLE_OK ) {
1476
+ if (results . curl_result != CURLE_OK ) {
1455
1477
fprintf (stderr ,
1456
1478
"PUT error: curl result=%d, HTTP code=%ld\n" ,
1457
- slot -> curl_result , slot -> http_code );
1479
+ results . curl_result , results . http_code );
1458
1480
/* We should attempt recovery? */
1459
1481
return 0 ;
1460
1482
}
0 commit comments