Fossil SCM

Only report server time skew once and at the very end of a sync.

drh 2013-09-05 01:48 trunk
Commit 051cf593b236b338fa1b2ed9a01d170590f319a8
1 file changed +20 -9
+20 -9
--- src/xfer.c
+++ src/xfer.c
@@ -1318,10 +1318,17 @@
13181318
#define SYNC_CLONE 0x0004
13191319
#define SYNC_PRIVATE 0x0008
13201320
#define SYNC_VERBOSE 0x0010
13211321
#define SYNC_RESYNC 0x0020
13221322
#endif
1323
+
1324
+/*
1325
+** Floating-point absolute value
1326
+*/
1327
+static double fossil_fabs(double x){
1328
+ return x>0.0 ? x : -x;
1329
+}
13231330
13241331
/*
13251332
** Sync to the host identified in g.urlName and g.urlPath. This
13261333
** routine is called by the client.
13271334
**
@@ -1356,10 +1363,11 @@
13561363
int nErr = 0; /* Number of errors */
13571364
int nRoundtrip= 0; /* Number of HTTP requests */
13581365
int nArtifactSent = 0; /* Total artifacts sent */
13591366
int nArtifactRcvd = 0; /* Total artifacts received */
13601367
const char *zOpType = 0;/* Push, Pull, Sync, Clone */
1368
+ double rSkew = 0.0; /* Maximum time skew */
13611369
13621370
if( db_get_boolean("dont-push", 0) ) syncFlags &= ~SYNC_PUSH;
13631371
if( (syncFlags & (SYNC_PUSH|SYNC_PULL|SYNC_CLONE))==0
13641372
&& configRcvMask==0 && configSendMask==0 ) return 0;
13651373
@@ -1554,19 +1562,12 @@
15541562
double rDiff;
15551563
sqlite3_snprintf(sizeof(zTime), zTime, "%.19s", &zLine[12]);
15561564
rDiff = db_double(9e99, "SELECT julianday('%q') - %.17g",
15571565
zTime, rArrivalTime);
15581566
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;
15681569
}
15691570
nCardRcvd++;
15701571
continue;
15711572
}
15721573
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
@@ -1856,10 +1857,20 @@
18561857
** information which is only sent on the second round.
18571858
*/
18581859
if( cloneSeqno<=0 && nCycle>1 ) go = 0;
18591860
};
18601861
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
+
18611872
fossil_force_newline();
18621873
fossil_print(
18631874
"%s finished with %lld bytes sent, %lld bytes received\n",
18641875
zOpType, nSent, nRcvd);
18651876
transport_close();
18661877
--- 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

Keyboard Shortcuts

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