Fossil SCM
Only report server time skew once and at the very end of a sync.
Commit
051cf593b236b338fa1b2ed9a01d170590f319a8
Parent
abf727105daa183…
1 file changed
+20
-9
+20
-9
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1318,10 +1318,17 @@ | ||
| 1318 | 1318 | #define SYNC_CLONE 0x0004 |
| 1319 | 1319 | #define SYNC_PRIVATE 0x0008 |
| 1320 | 1320 | #define SYNC_VERBOSE 0x0010 |
| 1321 | 1321 | #define SYNC_RESYNC 0x0020 |
| 1322 | 1322 | #endif |
| 1323 | + | |
| 1324 | +/* | |
| 1325 | +** Floating-point absolute value | |
| 1326 | +*/ | |
| 1327 | +static double fossil_fabs(double x){ | |
| 1328 | + return x>0.0 ? x : -x; | |
| 1329 | +} | |
| 1323 | 1330 | |
| 1324 | 1331 | /* |
| 1325 | 1332 | ** Sync to the host identified in g.urlName and g.urlPath. This |
| 1326 | 1333 | ** routine is called by the client. |
| 1327 | 1334 | ** |
| @@ -1356,10 +1363,11 @@ | ||
| 1356 | 1363 | int nErr = 0; /* Number of errors */ |
| 1357 | 1364 | int nRoundtrip= 0; /* Number of HTTP requests */ |
| 1358 | 1365 | int nArtifactSent = 0; /* Total artifacts sent */ |
| 1359 | 1366 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1360 | 1367 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1368 | + double rSkew = 0.0; /* Maximum time skew */ | |
| 1361 | 1369 | |
| 1362 | 1370 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1363 | 1371 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 |
| 1364 | 1372 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1365 | 1373 | |
| @@ -1554,19 +1562,12 @@ | ||
| 1554 | 1562 | double rDiff; |
| 1555 | 1563 | sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]); |
| 1556 | 1564 | rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g", |
| 1557 | 1565 | zTime, rArrivalTime); |
| 1558 | 1566 | if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0; |
| 1559 | - if( (rDiff*24.0*3600.0) > 10.0 ){ | |
| 1560 | - fossil_warning("*** time skew *** server is fast by %s", | |
| 1561 | - db_timespan_name(rDiff)); | |
| 1562 | - g.clockSkewSeen = 1; | |
| 1563 | - }else if( rDiff*24.0*3600.0 < -(blob_size(&recv)/5000.0 + 20.0) ){ | |
| 1564 | - fossil_warning("*** time skew *** server is slow by %s", | |
| 1565 | - db_timespan_name(-rDiff)); | |
| 1566 | - g.clockSkewSeen = 1; | |
| 1567 | - } | |
| 1567 | + if( rDiff*24.0*3600.0 >= -(blob_size(&recv)/5000.0 + 20) ) rDiff = 0.0; | |
| 1568 | + if( fossil_fabs(rDiff)>fossil_fabs(rSkew) ) rSkew = rDiff; | |
| 1568 | 1569 | } |
| 1569 | 1570 | nCardRcvd++; |
| 1570 | 1571 | continue; |
| 1571 | 1572 | } |
| 1572 | 1573 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| @@ -1856,10 +1857,20 @@ | ||
| 1856 | 1857 | ** information which is only sent on the second round. |
| 1857 | 1858 | */ |
| 1858 | 1859 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 1859 | 1860 | }; |
| 1860 | 1861 | transport_stats(&nSent, &nRcvd, 1); |
| 1862 | + if( (rSkew*24.0*3600.0) > 10.0 ){ | |
| 1863 | + fossil_warning("*** time skew *** server is fast by %s", | |
| 1864 | + db_timespan_name(rSkew)); | |
| 1865 | + g.clockSkewSeen = 1; | |
| 1866 | + }else if( rSkew*24.0*3600.0 < -10.0 ){ | |
| 1867 | + fossil_warning("*** time skew *** server is slow by %s", | |
| 1868 | + db_timespan_name(-rSkew)); | |
| 1869 | + g.clockSkewSeen = 1; | |
| 1870 | + } | |
| 1871 | + | |
| 1861 | 1872 | fossil_force_newline(); |
| 1862 | 1873 | fossil_print( |
| 1863 | 1874 | "%s finished with %lld bytes sent, %lld bytes received\n", |
| 1864 | 1875 | zOpType, nSent, nRcvd); |
| 1865 | 1876 | transport_close(); |
| 1866 | 1877 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1318,10 +1318,17 @@ | |
| 1318 | #define SYNC_CLONE 0x0004 |
| 1319 | #define SYNC_PRIVATE 0x0008 |
| 1320 | #define SYNC_VERBOSE 0x0010 |
| 1321 | #define SYNC_RESYNC 0x0020 |
| 1322 | #endif |
| 1323 | |
| 1324 | /* |
| 1325 | ** Sync to the host identified in g.urlName and g.urlPath. This |
| 1326 | ** routine is called by the client. |
| 1327 | ** |
| @@ -1356,10 +1363,11 @@ | |
| 1356 | int nErr = 0; /* Number of errors */ |
| 1357 | int nRoundtrip= 0; /* Number of HTTP requests */ |
| 1358 | int nArtifactSent = 0; /* Total artifacts sent */ |
| 1359 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1360 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1361 | |
| 1362 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1363 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 |
| 1364 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1365 | |
| @@ -1554,19 +1562,12 @@ | |
| 1554 | double rDiff; |
| 1555 | sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]); |
| 1556 | rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g", |
| 1557 | zTime, rArrivalTime); |
| 1558 | if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0; |
| 1559 | if( (rDiff*24.0*3600.0) > 10.0 ){ |
| 1560 | fossil_warning("*** time skew *** server is fast by %s", |
| 1561 | db_timespan_name(rDiff)); |
| 1562 | g.clockSkewSeen = 1; |
| 1563 | }else if( rDiff*24.0*3600.0 < -(blob_size(&recv)/5000.0 + 20.0) ){ |
| 1564 | fossil_warning("*** time skew *** server is slow by %s", |
| 1565 | db_timespan_name(-rDiff)); |
| 1566 | g.clockSkewSeen = 1; |
| 1567 | } |
| 1568 | } |
| 1569 | nCardRcvd++; |
| 1570 | continue; |
| 1571 | } |
| 1572 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| @@ -1856,10 +1857,20 @@ | |
| 1856 | ** information which is only sent on the second round. |
| 1857 | */ |
| 1858 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 1859 | }; |
| 1860 | transport_stats(&nSent, &nRcvd, 1); |
| 1861 | fossil_force_newline(); |
| 1862 | fossil_print( |
| 1863 | "%s finished with %lld bytes sent, %lld bytes received\n", |
| 1864 | zOpType, nSent, nRcvd); |
| 1865 | transport_close(); |
| 1866 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1318,10 +1318,17 @@ | |
| 1318 | #define SYNC_CLONE 0x0004 |
| 1319 | #define SYNC_PRIVATE 0x0008 |
| 1320 | #define SYNC_VERBOSE 0x0010 |
| 1321 | #define SYNC_RESYNC 0x0020 |
| 1322 | #endif |
| 1323 | |
| 1324 | /* |
| 1325 | ** Floating-point absolute value |
| 1326 | */ |
| 1327 | static double fossil_fabs(double x){ |
| 1328 | return x>0.0 ? x : -x; |
| 1329 | } |
| 1330 | |
| 1331 | /* |
| 1332 | ** Sync to the host identified in g.urlName and g.urlPath. This |
| 1333 | ** routine is called by the client. |
| 1334 | ** |
| @@ -1356,10 +1363,11 @@ | |
| 1363 | int nErr = 0; /* Number of errors */ |
| 1364 | int nRoundtrip= 0; /* Number of HTTP requests */ |
| 1365 | int nArtifactSent = 0; /* Total artifacts sent */ |
| 1366 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1367 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1368 | double rSkew = 0.0; /* Maximum time skew */ |
| 1369 | |
| 1370 | if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH; |
| 1371 | if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0 |
| 1372 | && configRcvMask==0 && configSendMask==0 ) return 0; |
| 1373 | |
| @@ -1554,19 +1562,12 @@ | |
| 1562 | double rDiff; |
| 1563 | sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]); |
| 1564 | rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g", |
| 1565 | zTime, rArrivalTime); |
| 1566 | if( rDiff>9e98 || rDiff<-9e98 ) rDiff = 0.0; |
| 1567 | if( rDiff*24.0*3600.0 >= -(blob_size(&recv)/5000.0 + 20) ) rDiff = 0.0; |
| 1568 | if( fossil_fabs(rDiff)>fossil_fabs(rSkew) ) rSkew = rDiff; |
| 1569 | } |
| 1570 | nCardRcvd++; |
| 1571 | continue; |
| 1572 | } |
| 1573 | xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); |
| @@ -1856,10 +1857,20 @@ | |
| 1857 | ** information which is only sent on the second round. |
| 1858 | */ |
| 1859 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 1860 | }; |
| 1861 | transport_stats(&nSent, &nRcvd, 1); |
| 1862 | if( (rSkew*24.0*3600.0) > 10.0 ){ |
| 1863 | fossil_warning("*** time skew *** server is fast by %s", |
| 1864 | db_timespan_name(rSkew)); |
| 1865 | g.clockSkewSeen = 1; |
| 1866 | }else if( rSkew*24.0*3600.0 < -10.0 ){ |
| 1867 | fossil_warning("*** time skew *** server is slow by %s", |
| 1868 | db_timespan_name(-rSkew)); |
| 1869 | g.clockSkewSeen = 1; |
| 1870 | } |
| 1871 | |
| 1872 | fossil_force_newline(); |
| 1873 | fossil_print( |
| 1874 | "%s finished with %lld bytes sent, %lld bytes received\n", |
| 1875 | zOpType, nSent, nRcvd); |
| 1876 | transport_close(); |
| 1877 |