Fossil SCM
Don't exit fatally during http_exchange, but return an error so partial sync can also be handled on network errors.
Commit
1317331eed6480437748168b4164c9f32f4edec3
Parent
ccc2bb73668c6c6…
2 files changed
+9
-4
+7
+9
-4
| --- src/http.c | ||
| +++ src/http.c | ||
| @@ -323,14 +323,18 @@ | ||
| 323 | 323 | } |
| 324 | 324 | }else if( rc==302 && fossil_strnicmp(zLine, "location:", 9)==0 ){ |
| 325 | 325 | int i, j; |
| 326 | 326 | |
| 327 | 327 | if ( --maxRedirect == 0){ |
| 328 | - fossil_fatal("redirect limit exceeded"); | |
| 328 | + fossil_warning("redirect limit exceeded"); | |
| 329 | + goto write_err; | |
| 329 | 330 | } |
| 330 | 331 | 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 | + } | |
| 332 | 336 | j = strlen(zLine) - 1; |
| 333 | 337 | while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){ |
| 334 | 338 | j -= 4; |
| 335 | 339 | zLine[j] = 0; |
| 336 | 340 | } |
| @@ -351,11 +355,11 @@ | ||
| 351 | 355 | isError = 1; |
| 352 | 356 | } |
| 353 | 357 | } |
| 354 | 358 | } |
| 355 | 359 | if( iLength<0 ){ |
| 356 | - fossil_fatal("server did not reply"); | |
| 360 | + fossil_warning("server did not reply"); | |
| 357 | 361 | goto write_err; |
| 358 | 362 | } |
| 359 | 363 | if( rc!=200 ){ |
| 360 | 364 | fossil_warning("\"location:\" missing from 302 redirect reply"); |
| 361 | 365 | goto write_err; |
| @@ -378,11 +382,12 @@ | ||
| 378 | 382 | if( z[i]==0 ) break; |
| 379 | 383 | } |
| 380 | 384 | z[j] = z[i]; |
| 381 | 385 | } |
| 382 | 386 | z[j] = 0; |
| 383 | - fossil_fatal("server sends error: %s", z); | |
| 387 | + fossil_warning("server sends error: %s", z); | |
| 388 | + goto write_err; | |
| 384 | 389 | } |
| 385 | 390 | if( isCompressed ) blob_uncompress(pReply, pReply); |
| 386 | 391 | |
| 387 | 392 | /* |
| 388 | 393 | ** Close the connection to the server if appropriate. |
| 389 | 394 |
| --- 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 @@ | ||
| 1559 | 1559 | fflush(stdout); |
| 1560 | 1560 | /* Exchange messages with the server */ |
| 1561 | 1561 | if( http_exchange(&send, &recv, (syncFlags & SYNC_CLONE)==0 || nCycle>0, |
| 1562 | 1562 | MAX_REDIRECTS) ){ |
| 1563 | 1563 | nErr++; |
| 1564 | + go = 2; | |
| 1564 | 1565 | break; |
| 1565 | 1566 | } |
| 1566 | 1567 | |
| 1567 | 1568 | /* Output current stats */ |
| 1568 | 1569 | if( syncFlags & SYNC_VERBOSE ){ |
| @@ -1936,7 +1937,13 @@ | ||
| 1936 | 1937 | fossil_print( |
| 1937 | 1938 | "%s finished with %lld bytes sent, %lld bytes received\n", |
| 1938 | 1939 | zOpType, nSent, nRcvd); |
| 1939 | 1940 | transport_close(&g.url); |
| 1940 | 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 | + } | |
| 1941 | 1948 | return nErr; |
| 1942 | 1949 | } |
| 1943 | 1950 |
| --- 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 |