Fossil SCM
Improve the decision about when to stop doing HTTP round-trips while doing a clone so that the clone will continue as long as new content is being received and we have not yet seen the "clone_seqno 0" card. Proposed fix for the issue discussed in [forum:/forumpost/60d48c2896|forum thread 60d48c2896].
Commit
ea5afad31f478396c53790a1cf9d7840cfee2be13303af7c4d90646f0a286d64
Parent
9956fa6ddefebb4…
1 file changed
+22
-26
+22
-26
| --- src/xfer.c | ||
| +++ src/xfer.c | ||
| @@ -1868,10 +1868,11 @@ | ||
| 1868 | 1868 | const char *zPCode = db_get("project-code", 0); |
| 1869 | 1869 | int nErr = 0; /* Number of errors */ |
| 1870 | 1870 | int nRoundtrip= 0; /* Number of HTTP requests */ |
| 1871 | 1871 | int nArtifactSent = 0; /* Total artifacts sent */ |
| 1872 | 1872 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1873 | + int nPriorArtifact = 0; /* Artifacts received on prior round-trips */ | |
| 1873 | 1874 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1874 | 1875 | double rSkew = 0.0; /* Maximum time skew */ |
| 1875 | 1876 | int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */ |
| 1876 | 1877 | int uvDoPush = 0; /* Generate uvfile messages to send to server */ |
| 1877 | 1878 | int uvPullOnly = 0; /* 1: pull-only. 2: pull-only warning issued */ |
| @@ -2196,10 +2197,11 @@ | ||
| 2196 | 2197 | nCardSent++; |
| 2197 | 2198 | } |
| 2198 | 2199 | go = 0; |
| 2199 | 2200 | nUvGimmeSent = 0; |
| 2200 | 2201 | nUvFileRcvd = 0; |
| 2202 | + nPriorArtifact = nArtifactRcvd; | |
| 2201 | 2203 | |
| 2202 | 2204 | /* Process the reply that came back from the server */ |
| 2203 | 2205 | while( blob_line(&recv, &xfer.line) ){ |
| 2204 | 2206 | if( blob_buffer(&xfer.line)[0]=='#' ){ |
| 2205 | 2207 | const char *zLine = blob_buffer(&xfer.line); |
| @@ -2628,48 +2630,42 @@ | ||
| 2628 | 2630 | } |
| 2629 | 2631 | nUncRcvd += blob_size(&recv); |
| 2630 | 2632 | blob_reset(&recv); |
| 2631 | 2633 | nCycle++; |
| 2632 | 2634 | |
| 2633 | - /* If we received one or more files on the previous exchange but | |
| 2634 | - ** there are still phantoms, then go another round. | |
| 2635 | - */ | |
| 2635 | + /* Set go to 1 if we need to continue the sync/push/pull/clone for | |
| 2636 | + ** another round. Set go to 0 if it is time to quit. */ | |
| 2636 | 2637 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 2637 | 2638 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 2638 | 2639 | go = 1; |
| 2639 | 2640 | mxPhantomReq = nFileRecv*2; |
| 2640 | 2641 | if( mxPhantomReq<200 ) mxPhantomReq = 200; |
| 2641 | 2642 | }else if( (syncFlags & SYNC_CLONE)!=0 && nFileRecv>0 ){ |
| 2642 | 2643 | go = 1; |
| 2644 | + }else if( xfer.nFileSent+xfer.nDeltaSent>0 || uvDoPush ){ | |
| 2645 | + /* Go another round if files are queued to send */ | |
| 2646 | + go = 1; | |
| 2647 | + }else if( xfer.nPrivIGot>0 && nCycle==1 ){ | |
| 2648 | + go = 1; | |
| 2649 | + }else if( (syncFlags & SYNC_CLONE)!=0 ){ | |
| 2650 | + if( nCycle==1 ){ | |
| 2651 | + go = 1; /* go at least two rounds on a clone */ | |
| 2652 | + }else if( cloneSeqno>0 && nArtifactRcvd>nPriorArtifact ){ | |
| 2653 | + /* Continue the clone until we see the clone_seqno 0" card or | |
| 2654 | + ** until we stop receiving artifacts */ | |
| 2655 | + go = 1; | |
| 2656 | + } | |
| 2657 | + }else if( nUvGimmeSent>0 && (nUvFileRcvd>0 || nCycle<3) ){ | |
| 2658 | + /* Continue looping as long as new uvfile cards are being received | |
| 2659 | + ** and uvgimme cards are being sent. */ | |
| 2660 | + go = 1; | |
| 2643 | 2661 | } |
| 2662 | + | |
| 2644 | 2663 | nCardRcvd = 0; |
| 2645 | 2664 | xfer.nFileRcvd = 0; |
| 2646 | 2665 | xfer.nDeltaRcvd = 0; |
| 2647 | 2666 | xfer.nDanglingFile = 0; |
| 2648 | - | |
| 2649 | - /* If we have one or more files queued to send, then go | |
| 2650 | - ** another round | |
| 2651 | - */ | |
| 2652 | - if( xfer.nFileSent+xfer.nDeltaSent>0 || uvDoPush ){ | |
| 2653 | - go = 1; | |
| 2654 | - } | |
| 2655 | - if( xfer.nPrivIGot>0 && nCycle==1 ) go = 1; | |
| 2656 | - | |
| 2657 | - /* If this is a clone, the go at least two rounds */ | |
| 2658 | - if( (syncFlags & SYNC_CLONE)!=0 && nCycle==1 ) go = 1; | |
| 2659 | - | |
| 2660 | - /* Stop the cycle if the server sends a "clone_seqno 0" card and | |
| 2661 | - ** we have gone at least two rounds. Always go at least two rounds | |
| 2662 | - ** on a clone in order to be sure to retrieve the configuration | |
| 2663 | - ** information which is only sent on the second round. | |
| 2664 | - */ | |
| 2665 | - if( cloneSeqno<=0 && nCycle>1 ) go = 0; | |
| 2666 | - | |
| 2667 | - /* Continue looping as long as new uvfile cards are being received | |
| 2668 | - ** and uvgimme cards are being sent. */ | |
| 2669 | - if( nUvGimmeSent>0 && (nUvFileRcvd>0 || nCycle<3) ) go = 1; | |
| 2670 | - | |
| 2671 | 2667 | db_multi_exec("DROP TABLE onremote; DROP TABLE unk;"); |
| 2672 | 2668 | if( go ){ |
| 2673 | 2669 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2674 | 2670 | }else{ |
| 2675 | 2671 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2676 | 2672 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1868,10 +1868,11 @@ | |
| 1868 | const char *zPCode = db_get("project-code", 0); |
| 1869 | int nErr = 0; /* Number of errors */ |
| 1870 | int nRoundtrip= 0; /* Number of HTTP requests */ |
| 1871 | int nArtifactSent = 0; /* Total artifacts sent */ |
| 1872 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1873 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1874 | double rSkew = 0.0; /* Maximum time skew */ |
| 1875 | int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */ |
| 1876 | int uvDoPush = 0; /* Generate uvfile messages to send to server */ |
| 1877 | int uvPullOnly = 0; /* 1: pull-only. 2: pull-only warning issued */ |
| @@ -2196,10 +2197,11 @@ | |
| 2196 | nCardSent++; |
| 2197 | } |
| 2198 | go = 0; |
| 2199 | nUvGimmeSent = 0; |
| 2200 | nUvFileRcvd = 0; |
| 2201 | |
| 2202 | /* Process the reply that came back from the server */ |
| 2203 | while( blob_line(&recv, &xfer.line) ){ |
| 2204 | if( blob_buffer(&xfer.line)[0]=='#' ){ |
| 2205 | const char *zLine = blob_buffer(&xfer.line); |
| @@ -2628,48 +2630,42 @@ | |
| 2628 | } |
| 2629 | nUncRcvd += blob_size(&recv); |
| 2630 | blob_reset(&recv); |
| 2631 | nCycle++; |
| 2632 | |
| 2633 | /* If we received one or more files on the previous exchange but |
| 2634 | ** there are still phantoms, then go another round. |
| 2635 | */ |
| 2636 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 2637 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 2638 | go = 1; |
| 2639 | mxPhantomReq = nFileRecv*2; |
| 2640 | if( mxPhantomReq<200 ) mxPhantomReq = 200; |
| 2641 | }else if( (syncFlags & SYNC_CLONE)!=0 && nFileRecv>0 ){ |
| 2642 | go = 1; |
| 2643 | } |
| 2644 | nCardRcvd = 0; |
| 2645 | xfer.nFileRcvd = 0; |
| 2646 | xfer.nDeltaRcvd = 0; |
| 2647 | xfer.nDanglingFile = 0; |
| 2648 | |
| 2649 | /* If we have one or more files queued to send, then go |
| 2650 | ** another round |
| 2651 | */ |
| 2652 | if( xfer.nFileSent+xfer.nDeltaSent>0 || uvDoPush ){ |
| 2653 | go = 1; |
| 2654 | } |
| 2655 | if( xfer.nPrivIGot>0 && nCycle==1 ) go = 1; |
| 2656 | |
| 2657 | /* If this is a clone, the go at least two rounds */ |
| 2658 | if( (syncFlags & SYNC_CLONE)!=0 && nCycle==1 ) go = 1; |
| 2659 | |
| 2660 | /* Stop the cycle if the server sends a "clone_seqno 0" card and |
| 2661 | ** we have gone at least two rounds. Always go at least two rounds |
| 2662 | ** on a clone in order to be sure to retrieve the configuration |
| 2663 | ** information which is only sent on the second round. |
| 2664 | */ |
| 2665 | if( cloneSeqno<=0 && nCycle>1 ) go = 0; |
| 2666 | |
| 2667 | /* Continue looping as long as new uvfile cards are being received |
| 2668 | ** and uvgimme cards are being sent. */ |
| 2669 | if( nUvGimmeSent>0 && (nUvFileRcvd>0 || nCycle<3) ) go = 1; |
| 2670 | |
| 2671 | db_multi_exec("DROP TABLE onremote; DROP TABLE unk;"); |
| 2672 | if( go ){ |
| 2673 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2674 | }else{ |
| 2675 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2676 |
| --- src/xfer.c | |
| +++ src/xfer.c | |
| @@ -1868,10 +1868,11 @@ | |
| 1868 | const char *zPCode = db_get("project-code", 0); |
| 1869 | int nErr = 0; /* Number of errors */ |
| 1870 | int nRoundtrip= 0; /* Number of HTTP requests */ |
| 1871 | int nArtifactSent = 0; /* Total artifacts sent */ |
| 1872 | int nArtifactRcvd = 0; /* Total artifacts received */ |
| 1873 | int nPriorArtifact = 0; /* Artifacts received on prior round-trips */ |
| 1874 | const char *zOpType = 0;/* Push, Pull, Sync, Clone */ |
| 1875 | double rSkew = 0.0; /* Maximum time skew */ |
| 1876 | int uvHashSent = 0; /* The "pragma uv-hash" message has been sent */ |
| 1877 | int uvDoPush = 0; /* Generate uvfile messages to send to server */ |
| 1878 | int uvPullOnly = 0; /* 1: pull-only. 2: pull-only warning issued */ |
| @@ -2196,10 +2197,11 @@ | |
| 2197 | nCardSent++; |
| 2198 | } |
| 2199 | go = 0; |
| 2200 | nUvGimmeSent = 0; |
| 2201 | nUvFileRcvd = 0; |
| 2202 | nPriorArtifact = nArtifactRcvd; |
| 2203 | |
| 2204 | /* Process the reply that came back from the server */ |
| 2205 | while( blob_line(&recv, &xfer.line) ){ |
| 2206 | if( blob_buffer(&xfer.line)[0]=='#' ){ |
| 2207 | const char *zLine = blob_buffer(&xfer.line); |
| @@ -2628,48 +2630,42 @@ | |
| 2630 | } |
| 2631 | nUncRcvd += blob_size(&recv); |
| 2632 | blob_reset(&recv); |
| 2633 | nCycle++; |
| 2634 | |
| 2635 | /* Set go to 1 if we need to continue the sync/push/pull/clone for |
| 2636 | ** another round. Set go to 0 if it is time to quit. */ |
| 2637 | nFileRecv = xfer.nFileRcvd + xfer.nDeltaRcvd + xfer.nDanglingFile; |
| 2638 | if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ |
| 2639 | go = 1; |
| 2640 | mxPhantomReq = nFileRecv*2; |
| 2641 | if( mxPhantomReq<200 ) mxPhantomReq = 200; |
| 2642 | }else if( (syncFlags & SYNC_CLONE)!=0 && nFileRecv>0 ){ |
| 2643 | go = 1; |
| 2644 | }else if( xfer.nFileSent+xfer.nDeltaSent>0 || uvDoPush ){ |
| 2645 | /* Go another round if files are queued to send */ |
| 2646 | go = 1; |
| 2647 | }else if( xfer.nPrivIGot>0 && nCycle==1 ){ |
| 2648 | go = 1; |
| 2649 | }else if( (syncFlags & SYNC_CLONE)!=0 ){ |
| 2650 | if( nCycle==1 ){ |
| 2651 | go = 1; /* go at least two rounds on a clone */ |
| 2652 | }else if( cloneSeqno>0 && nArtifactRcvd>nPriorArtifact ){ |
| 2653 | /* Continue the clone until we see the clone_seqno 0" card or |
| 2654 | ** until we stop receiving artifacts */ |
| 2655 | go = 1; |
| 2656 | } |
| 2657 | }else if( nUvGimmeSent>0 && (nUvFileRcvd>0 || nCycle<3) ){ |
| 2658 | /* Continue looping as long as new uvfile cards are being received |
| 2659 | ** and uvgimme cards are being sent. */ |
| 2660 | go = 1; |
| 2661 | } |
| 2662 | |
| 2663 | nCardRcvd = 0; |
| 2664 | xfer.nFileRcvd = 0; |
| 2665 | xfer.nDeltaRcvd = 0; |
| 2666 | xfer.nDanglingFile = 0; |
| 2667 | db_multi_exec("DROP TABLE onremote; DROP TABLE unk;"); |
| 2668 | if( go ){ |
| 2669 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2670 | }else{ |
| 2671 | manifest_crosslink_end(MC_PERMIT_HOOKS); |
| 2672 |