Fossil SCM

Don't exit fatally during http_exchange, but return an error so partial sync can also be handled on network errors.

andybradford 2014-05-05 03:54 UTC per-round-trip-commit
Commit 1317331eed6480437748168b4164c9f32f4edec3
2 files changed +9 -4 +7
+9 -4
--- src/http.c
+++ src/http.c
@@ -323,14 +323,18 @@
323323
}
324324
}else if( rc==302 && fossil_strnicmp(zLine, "location:", 9)==0 ){
325325
int i, j;
326326
327327
if ( --maxRedirect == 0){
328
- fossil_fatal("redirect limit exceeded");
328
+ fossil_warning("redirect limit exceeded");
329
+ goto write_err;
329330
}
330331
for(i=9; zLine[i] && zLine[i]==' '; i++){}
331
- if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
332
+ if( zLine[i]==0 ){
333
+ fossil_warning("malformed redirect: %s", zLine);
334
+ goto write_err;
335
+ }
332336
j = strlen(zLine) - 1;
333337
while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
334338
j -= 4;
335339
zLine[j] = 0;
336340
}
@@ -351,11 +355,11 @@
351355
isError = 1;
352356
}
353357
}
354358
}
355359
if( iLength<0 ){
356
- fossil_fatal("server did not reply");
360
+ fossil_warning("server did not reply");
357361
goto write_err;
358362
}
359363
if( rc!=200 ){
360364
fossil_warning("\"location:\" missing from 302 redirect reply");
361365
goto write_err;
@@ -378,11 +382,12 @@
378382
if( z[i]==0 ) break;
379383
}
380384
z[j] = z[i];
381385
}
382386
z[j] = 0;
383
- fossil_fatal("server sends error: %s", z);
387
+ fossil_warning("server sends error: %s", z);
388
+ goto write_err;
384389
}
385390
if( isCompressed ) blob_uncompress(pReply, pReply);
386391
387392
/*
388393
** Close the connection to the server if appropriate.
389394
--- src/http.c
+++ src/http.c
@@ -323,14 +323,18 @@
323 }
324 }else if( rc==302 && fossil_strnicmp(zLine, "location:", 9)==0 ){
325 int i, j;
326
327 if ( --maxRedirect == 0){
328 fossil_fatal("redirect limit exceeded");
 
329 }
330 for(i=9; zLine[i] && zLine[i]==' '; i++){}
331 if( zLine[i]==0 ) fossil_fatal("malformed redirect: %s", zLine);
 
 
 
332 j = strlen(zLine) - 1;
333 while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
334 j -= 4;
335 zLine[j] = 0;
336 }
@@ -351,11 +355,11 @@
351 isError = 1;
352 }
353 }
354 }
355 if( iLength<0 ){
356 fossil_fatal("server did not reply");
357 goto write_err;
358 }
359 if( rc!=200 ){
360 fossil_warning("\"location:\" missing from 302 redirect reply");
361 goto write_err;
@@ -378,11 +382,12 @@
378 if( z[i]==0 ) break;
379 }
380 z[j] = z[i];
381 }
382 z[j] = 0;
383 fossil_fatal("server sends error: %s", z);
 
384 }
385 if( isCompressed ) blob_uncompress(pReply, pReply);
386
387 /*
388 ** Close the connection to the server if appropriate.
389
--- src/http.c
+++ src/http.c
@@ -323,14 +323,18 @@
323 }
324 }else if( rc==302 && fossil_strnicmp(zLine, "location:", 9)==0 ){
325 int i, j;
326
327 if ( --maxRedirect == 0){
328 fossil_warning("redirect limit exceeded");
329 goto write_err;
330 }
331 for(i=9; zLine[i] && zLine[i]==' '; i++){}
332 if( zLine[i]==0 ){
333 fossil_warning("malformed redirect: %s", zLine);
334 goto write_err;
335 }
336 j = strlen(zLine) - 1;
337 while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
338 j -= 4;
339 zLine[j] = 0;
340 }
@@ -351,11 +355,11 @@
355 isError = 1;
356 }
357 }
358 }
359 if( iLength<0 ){
360 fossil_warning("server did not reply");
361 goto write_err;
362 }
363 if( rc!=200 ){
364 fossil_warning("\"location:\" missing from 302 redirect reply");
365 goto write_err;
@@ -378,11 +382,12 @@
382 if( z[i]==0 ) break;
383 }
384 z[j] = z[i];
385 }
386 z[j] = 0;
387 fossil_warning("server sends error: %s", z);
388 goto write_err;
389 }
390 if( isCompressed ) blob_uncompress(pReply, pReply);
391
392 /*
393 ** Close the connection to the server if appropriate.
394
+7
--- src/xfer.c
+++ src/xfer.c
@@ -1559,10 +1559,11 @@
15591559
fflush(stdout);
15601560
/* Exchange messages with the server */
15611561
if( http_exchange(&send, &recv, (syncFlags & SYNC_CLONE)==0 || nCycle>0,
15621562
MAX_REDIRECTS) ){
15631563
nErr++;
1564
+ go = 2;
15641565
break;
15651566
}
15661567
15671568
/* Output current stats */
15681569
if( syncFlags & SYNC_VERBOSE ){
@@ -1936,7 +1937,13 @@
19361937
fossil_print(
19371938
"%s finished with %lld bytes sent, %lld bytes received\n",
19381939
zOpType, nSent, nRcvd);
19391940
transport_close(&g.url);
19401941
transport_global_shutdown(&g.url);
1942
+ if( nErr && go==2 ){
1943
+ db_multi_exec("DROP TABLE onremote");
1944
+ manifest_crosslink_end(MC_PERMIT_HOOKS);
1945
+ content_enable_dephantomize(1);
1946
+ db_end_transaction(0);
1947
+ }
19411948
return nErr;
19421949
}
19431950
--- src/xfer.c
+++ src/xfer.c
@@ -1559,10 +1559,11 @@
1559 fflush(stdout);
1560 /* Exchange messages with the server */
1561 if( http_exchange(&send, &recv, (syncFlags & SYNC_CLONE)==0 || nCycle>0,
1562 MAX_REDIRECTS) ){
1563 nErr++;
 
1564 break;
1565 }
1566
1567 /* Output current stats */
1568 if( syncFlags & SYNC_VERBOSE ){
@@ -1936,7 +1937,13 @@
1936 fossil_print(
1937 "%s finished with %lld bytes sent, %lld bytes received\n",
1938 zOpType, nSent, nRcvd);
1939 transport_close(&g.url);
1940 transport_global_shutdown(&g.url);
 
 
 
 
 
 
1941 return nErr;
1942 }
1943
--- src/xfer.c
+++ src/xfer.c
@@ -1559,10 +1559,11 @@
1559 fflush(stdout);
1560 /* Exchange messages with the server */
1561 if( http_exchange(&send, &recv, (syncFlags & SYNC_CLONE)==0 || nCycle>0,
1562 MAX_REDIRECTS) ){
1563 nErr++;
1564 go = 2;
1565 break;
1566 }
1567
1568 /* Output current stats */
1569 if( syncFlags & SYNC_VERBOSE ){
@@ -1936,7 +1937,13 @@
1937 fossil_print(
1938 "%s finished with %lld bytes sent, %lld bytes received\n",
1939 zOpType, nSent, nRcvd);
1940 transport_close(&g.url);
1941 transport_global_shutdown(&g.url);
1942 if( nErr && go==2 ){
1943 db_multi_exec("DROP TABLE onremote");
1944 manifest_crosslink_end(MC_PERMIT_HOOKS);
1945 content_enable_dephantomize(1);
1946 db_end_transaction(0);
1947 }
1948 return nErr;
1949 }
1950

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button