Fossil SCM

Improvements to comments in the sync logic. No changes to code.

drh 2020-04-12 19:55 sync-improvements
Commit 18262347369e11f3a419c005c4420c95230d1fb0c2c9855576f9f6462c7bc29b
1 file changed +47 -37
+47 -37
--- src/xfer.c
+++ src/xfer.c
@@ -1209,11 +1209,11 @@
12091209
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
12101210
12111211
/* file HASH SIZE \n CONTENT
12121212
** file HASH DELTASRC SIZE \n CONTENT
12131213
**
1214
- ** Accept a file from the client.
1214
+ ** Server accepts a file from the client.
12151215
*/
12161216
if( blob_eq(&xfer.aToken[0], "file") ){
12171217
if( !isPush ){
12181218
cgi_reset_content();
12191219
@ error not\sauthorized\sto\swrite
@@ -1230,11 +1230,11 @@
12301230
}else
12311231
12321232
/* cfile HASH USIZE CSIZE \n CONTENT
12331233
** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
12341234
**
1235
- ** Accept a file from the client.
1235
+ ** Server accepts a compressed file from the client.
12361236
*/
12371237
if( blob_eq(&xfer.aToken[0], "cfile") ){
12381238
if( !isPush ){
12391239
cgi_reset_content();
12401240
@ error not\sauthorized\sto\swrite
@@ -1250,11 +1250,11 @@
12501250
}
12511251
}else
12521252
12531253
/* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
12541254
**
1255
- ** Accept an unversioned file from the client.
1255
+ ** Server accepts an unversioned file from the client.
12561256
*/
12571257
if( blob_eq(&xfer.aToken[0], "uvfile") ){
12581258
xfer_accept_unversioned_file(&xfer, g.perm.WrUnver);
12591259
if( blob_size(&xfer.err) ){
12601260
cgi_reset_content();
@@ -1264,11 +1264,11 @@
12641264
}
12651265
}else
12661266
12671267
/* gimme HASH
12681268
**
1269
- ** Client is requesting a file. Send it.
1269
+ ** Client is requesting a file from the server. Send it.
12701270
*/
12711271
if( blob_eq(&xfer.aToken[0], "gimme")
12721272
&& xfer.nToken==2
12731273
&& blob_is_hname(&xfer.aToken[1])
12741274
){
@@ -1281,11 +1281,11 @@
12811281
}
12821282
}else
12831283
12841284
/* uvgimme NAME
12851285
**
1286
- ** Client is requesting an unversioned file. Send it.
1286
+ ** Client is requesting an unversioned file from the server. Send it.
12871287
*/
12881288
if( blob_eq(&xfer.aToken[0], "uvgimme")
12891289
&& xfer.nToken==2
12901290
&& blob_is_filename(&xfer.aToken[1])
12911291
){
@@ -1408,11 +1408,12 @@
14081408
@ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x"))
14091409
}else
14101410
14111411
/* login USER NONCE SIGNATURE
14121412
**
1413
- ** Check for a valid login. This has to happen before anything else.
1413
+ ** The client has sent login credentials to the server.
1414
+ ** Validate the login. This has to happen before anything else.
14141415
** The client can send multiple logins. Permissions are cumulative.
14151416
*/
14161417
if( blob_eq(&xfer.aToken[0], "login")
14171418
&& xfer.nToken==4
14181419
){
@@ -1430,11 +1431,11 @@
14301431
}
14311432
}else
14321433
14331434
/* reqconfig NAME
14341435
**
1435
- ** Request a configuration value
1436
+ ** Client is requesting a configuration value from the server
14361437
*/
14371438
if( blob_eq(&xfer.aToken[0], "reqconfig")
14381439
&& xfer.nToken==2
14391440
){
14401441
if( g.perm.Read ){
@@ -1449,12 +1450,12 @@
14491450
}
14501451
}else
14511452
14521453
/* config NAME SIZE \n CONTENT
14531454
**
1454
- ** Receive a configuration value from the client. This is only
1455
- ** permitted for high-privilege users.
1455
+ ** Client has sent a configuration value to the server.
1456
+ ** This is only permitted for high-privilege users.
14561457
*/
14571458
if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3
14581459
&& blob_is_int(&xfer.aToken[2], &size) ){
14591460
const char *zName = blob_str(&xfer.aToken[1]);
14601461
Blob content;
@@ -1494,11 +1495,11 @@
14941495
}else
14951496
14961497
14971498
/* private
14981499
**
1499
- ** This card indicates that the next "file" or "cfile" will contain
1500
+ ** The client card indicates that the next "file" or "cfile" will contain
15001501
** private content.
15011502
*/
15021503
if( blob_eq(&xfer.aToken[0], "private") ){
15031504
if( !g.perm.Private ){
15041505
server_private_xfer_not_authorized();
@@ -1515,10 +1516,12 @@
15151516
** ignored.
15161517
*/
15171518
if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){
15181519
15191520
/* pragma send-private
1521
+ **
1522
+ ** The client is requesting private artifacts.
15201523
**
15211524
** If the user has the "x" privilege (which must be set explicitly -
15221525
** it is not automatic with "a" or "s") then this pragma causes
15231526
** private information to be pulled in addition to public records.
15241527
*/
@@ -1531,19 +1534,22 @@
15311534
}
15321535
}
15331536
15341537
/* pragma send-catalog
15351538
**
1536
- ** Send igot cards for all known artifacts.
1539
+ ** The client wants to see igot cards for all known artifacts.
1540
+ ** This is used as part of "sync --verily" to help ensure that
1541
+ ** no artifacts have been missed on prior syncs.
15371542
*/
15381543
if( blob_eq(&xfer.aToken[1], "send-catalog") ){
15391544
xfer.resync = 0x7fffffff;
15401545
}
15411546
15421547
/* pragma client-version VERSION
15431548
**
1544
- ** Let the server know what version of Fossil is running on the client.
1549
+ ** The client announces to the server what version of Fossil it
1550
+ ** is running.
15451551
*/
15461552
if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){
15471553
xfer.clientVersion = atoi(blob_str(&xfer.aToken[2]));
15481554
}
15491555
@@ -1570,11 +1576,11 @@
15701576
15711577
/* pragma ci-lock CHECKIN-HASH CLIENT-ID
15721578
**
15731579
** The client wants to make non-branch commit against the check-in
15741580
** identified by CHECKIN-HASH. The server will remember this and
1575
- ** subsequent ci-lock request from different clients will generate
1581
+ ** subsequent ci-lock requests from different clients will generate
15761582
** a ci-lock-fail pragma in the reply.
15771583
*/
15781584
if( blob_eq(&xfer.aToken[1], "ci-lock")
15791585
&& xfer.nToken==4
15801586
&& blob_is_hname(&xfer.aToken[2])
@@ -1876,11 +1882,12 @@
18761882
" SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;"
18771883
);
18781884
}
18791885
18801886
/*
1881
- ** Always begin with a clone, pull, or push message
1887
+ ** The request from the client always begin with a clone, pull,
1888
+ ** or push message.
18821889
*/
18831890
blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER);
18841891
if( syncFlags & SYNC_CLONE ){
18851892
blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
18861893
syncFlags &= ~(SYNC_PUSH|SYNC_PULL);
@@ -1918,20 +1925,19 @@
19181925
"CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
19191926
);
19201927
manifest_crosslink_begin();
19211928
19221929
1923
- /* Send back the most recently received cookie. Let the server
1924
- ** figure out if this is a cookie that it cares about.
1930
+ /* Client sends the most recently received cookie back to the server.
1931
+ ** Let the server figure out if this is a cookie that it cares about.
19251932
*/
19261933
zCookie = db_get("cookie", 0);
19271934
if( zCookie ){
19281935
blob_appendf(&send, "cookie %s\n", zCookie);
19291936
}
19301937
1931
- /* Generate gimme cards for phantoms and leaf cards
1932
- ** for all leaves.
1938
+ /* Client sends gimme cards for phantoms
19331939
*/
19341940
if( (syncFlags & SYNC_PULL)!=0
19351941
|| ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1)
19361942
){
19371943
request_phantoms(&xfer, mxPhantomReq);
@@ -1940,11 +1946,11 @@
19401946
send_unsent(&xfer);
19411947
nCardSent += send_unclustered(&xfer);
19421948
if( syncFlags & SYNC_PRIVATE ) send_private(&xfer);
19431949
}
19441950
1945
- /* Send configuration parameter requests. On a clone, delay sending
1951
+ /* Client sends configuration parameter requests. On a clone, delay sending
19461952
** this until the second cycle since the login card might fail on
19471953
** the first cycle.
19481954
*/
19491955
if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){
19501956
const char *zName;
@@ -1957,13 +1963,13 @@
19571963
}
19581964
origConfigRcvMask = configRcvMask;
19591965
configRcvMask = 0;
19601966
}
19611967
1962
- /* Send a request to sync unversioned files. On a clone, delay sending
1963
- ** this until the second cycle since the login card might fail on
1964
- ** the first cycle.
1968
+ /* Client sends a request to sync unversioned files.
1969
+ ** On a clone, delay sending this until the second cycle since
1970
+ ** the login card might fail on the first cycle.
19651971
*/
19661972
if( (syncFlags & SYNC_UNVERSIONED)!=0
19671973
&& ((syncFlags & SYNC_CLONE)==0 || nCycle>0)
19681974
&& !uvHashSent
19691975
){
@@ -1970,11 +1976,12 @@
19701976
blob_appendf(&send, "pragma uv-hash %s\n", unversioned_content_hash(0));
19711977
nCardSent++;
19721978
uvHashSent = 1;
19731979
}
19741980
1975
- /* Send configuration parameters being pushed */
1981
+ /* On a "fossil config push", the client send configuration parameters
1982
+ ** being pushed up to the server */
19761983
if( configSendMask ){
19771984
if( zOpType==0 ) zOpType = "Push";
19781985
nCardSent += configure_send_group(xfer.pOut, configSendMask, 0);
19791986
configSendMask = 0;
19801987
}
@@ -2030,11 +2037,11 @@
20302037
zCkinLock = 0;
20312038
}else if( zClientId ){
20322039
blob_appendf(&send, "pragma ci-unlock %s\n", zClientId);
20332040
}
20342041
2035
- /* Append randomness to the end of the message. This makes all
2042
+ /* Append randomness to the end of the uplink message. This makes all
20362043
** messages unique so that that the login-card nonce will always
20372044
** be unique.
20382045
*/
20392046
zRandomness = db_text(0, "SELECT hex(randomblob(20))");
20402047
blob_appendf(&send, "# %s\n", zRandomness);
@@ -2132,30 +2139,30 @@
21322139
}
21332140
21342141
/* file HASH SIZE \n CONTENT
21352142
** file HASH DELTASRC SIZE \n CONTENT
21362143
**
2137
- ** Receive a file transmitted from the server.
2144
+ ** Client receives a file transmitted from the server.
21382145
*/
21392146
if( blob_eq(&xfer.aToken[0],"file") ){
21402147
xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
21412148
nArtifactRcvd++;
21422149
}else
21432150
21442151
/* cfile HASH USIZE CSIZE \n CONTENT
21452152
** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
21462153
**
2147
- ** Receive a compressed file transmitted from the server.
2154
+ ** Client receives a compressed file transmitted from the server.
21482155
*/
21492156
if( blob_eq(&xfer.aToken[0],"cfile") ){
21502157
xfer_accept_compressed_file(&xfer, 0, 0);
21512158
nArtifactRcvd++;
21522159
}else
21532160
21542161
/* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
21552162
**
2156
- ** Accept an unversioned file from the server.
2163
+ ** Client accepts an unversioned file from the server.
21572164
*/
21582165
if( blob_eq(&xfer.aToken[0], "uvfile") ){
21592166
xfer_accept_unversioned_file(&xfer, 1);
21602167
nArtifactRcvd++;
21612168
nUvFileRcvd++;
@@ -2165,13 +2172,14 @@
21652172
}
21662173
}else
21672174
21682175
/* gimme HASH
21692176
**
2170
- ** Server is requesting a file. If the file is a manifest, assume
2171
- ** that the server will also want to know all of the content files
2172
- ** associated with the manifest and send those too.
2177
+ ** Client receives an artifact request from the server.
2178
+ ** If the file is a manifest, assume that the server will also want
2179
+ ** to know all of the content artifacts associated with the manifest
2180
+ ** and send those too.
21732181
*/
21742182
if( blob_eq(&xfer.aToken[0], "gimme")
21752183
&& xfer.nToken==2
21762184
&& blob_is_hname(&xfer.aToken[1])
21772185
){
@@ -2284,11 +2292,11 @@
22842292
}else
22852293
22862294
/* push SERVERCODE PRODUCTCODE
22872295
**
22882296
** Should only happen in response to a clone. This message tells
2289
- ** the client what product to use for the new database.
2297
+ ** the client what product code to use for the new database.
22902298
*/
22912299
if( blob_eq(&xfer.aToken[0],"push")
22922300
&& xfer.nToken==3
22932301
&& (syncFlags & SYNC_CLONE)!=0
22942302
&& blob_is_hname(&xfer.aToken[2])
@@ -2301,11 +2309,11 @@
23012309
nCardSent++;
23022310
}else
23032311
23042312
/* config NAME SIZE \n CONTENT
23052313
**
2306
- ** Receive a configuration value from the server.
2314
+ ** Client receive a configuration value from the server.
23072315
**
23082316
** The received configuration setting is silently ignored if it was
23092317
** not requested by a prior "reqconfig" sent from client to server.
23102318
*/
23112319
if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3
@@ -2323,11 +2331,11 @@
23232331
}else
23242332
23252333
23262334
/* cookie TEXT
23272335
**
2328
- ** The server might include a cookie in its reply. The client
2336
+ ** The client reserves a cookie from the server. The client
23292337
** should remember this cookie and send it back to the server
23302338
** in its next query.
23312339
**
23322340
** Each cookie received overwrites the prior cookie from the
23332341
** same server.
@@ -2337,12 +2345,12 @@
23372345
}else
23382346
23392347
23402348
/* private
23412349
**
2342
- ** This card indicates that the next "file" or "cfile" will contain
2343
- ** private content.
2350
+ ** The server tells the client that the next "file" or "cfile" will
2351
+ ** contain private content.
23442352
*/
23452353
if( blob_eq(&xfer.aToken[0], "private") ){
23462354
xfer.nextIsPrivate = 1;
23472355
}else
23482356
@@ -2358,11 +2366,12 @@
23582366
blob_is_int(&xfer.aToken[1], &cloneSeqno);
23592367
}else
23602368
23612369
/* message MESSAGE
23622370
**
2363
- ** Print a message. Similar to "error" but does not stop processing.
2371
+ ** A message is received from the server. Print it.
2372
+ ** Similar to "error" but does not stop processing.
23642373
**
23652374
** If the "login failed" message is seen, clear the sync password prior
23662375
** to the next cycle.
23672376
*/
23682377
if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){
@@ -2427,11 +2436,12 @@
24272436
}
24282437
}else
24292438
24302439
/* error MESSAGE
24312440
**
2432
- ** Report an error and abandon the sync session.
2441
+ ** The server is reporting an error. The client will abandon
2442
+ ** the sync session.
24332443
**
24342444
** Except, when cloning we will sometimes get an error on the
24352445
** first message exchange because the project-code is unknown
24362446
** and so the login card on the request was invalid. The project-code
24372447
** is returned in the reply before the error card, so second and
24382448
--- src/xfer.c
+++ src/xfer.c
@@ -1209,11 +1209,11 @@
1209 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1210
1211 /* file HASH SIZE \n CONTENT
1212 ** file HASH DELTASRC SIZE \n CONTENT
1213 **
1214 ** Accept a file from the client.
1215 */
1216 if( blob_eq(&xfer.aToken[0], "file") ){
1217 if( !isPush ){
1218 cgi_reset_content();
1219 @ error not\sauthorized\sto\swrite
@@ -1230,11 +1230,11 @@
1230 }else
1231
1232 /* cfile HASH USIZE CSIZE \n CONTENT
1233 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
1234 **
1235 ** Accept a file from the client.
1236 */
1237 if( blob_eq(&xfer.aToken[0], "cfile") ){
1238 if( !isPush ){
1239 cgi_reset_content();
1240 @ error not\sauthorized\sto\swrite
@@ -1250,11 +1250,11 @@
1250 }
1251 }else
1252
1253 /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
1254 **
1255 ** Accept an unversioned file from the client.
1256 */
1257 if( blob_eq(&xfer.aToken[0], "uvfile") ){
1258 xfer_accept_unversioned_file(&xfer, g.perm.WrUnver);
1259 if( blob_size(&xfer.err) ){
1260 cgi_reset_content();
@@ -1264,11 +1264,11 @@
1264 }
1265 }else
1266
1267 /* gimme HASH
1268 **
1269 ** Client is requesting a file. Send it.
1270 */
1271 if( blob_eq(&xfer.aToken[0], "gimme")
1272 && xfer.nToken==2
1273 && blob_is_hname(&xfer.aToken[1])
1274 ){
@@ -1281,11 +1281,11 @@
1281 }
1282 }else
1283
1284 /* uvgimme NAME
1285 **
1286 ** Client is requesting an unversioned file. Send it.
1287 */
1288 if( blob_eq(&xfer.aToken[0], "uvgimme")
1289 && xfer.nToken==2
1290 && blob_is_filename(&xfer.aToken[1])
1291 ){
@@ -1408,11 +1408,12 @@
1408 @ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x"))
1409 }else
1410
1411 /* login USER NONCE SIGNATURE
1412 **
1413 ** Check for a valid login. This has to happen before anything else.
 
1414 ** The client can send multiple logins. Permissions are cumulative.
1415 */
1416 if( blob_eq(&xfer.aToken[0], "login")
1417 && xfer.nToken==4
1418 ){
@@ -1430,11 +1431,11 @@
1430 }
1431 }else
1432
1433 /* reqconfig NAME
1434 **
1435 ** Request a configuration value
1436 */
1437 if( blob_eq(&xfer.aToken[0], "reqconfig")
1438 && xfer.nToken==2
1439 ){
1440 if( g.perm.Read ){
@@ -1449,12 +1450,12 @@
1449 }
1450 }else
1451
1452 /* config NAME SIZE \n CONTENT
1453 **
1454 ** Receive a configuration value from the client. This is only
1455 ** permitted for high-privilege users.
1456 */
1457 if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3
1458 && blob_is_int(&xfer.aToken[2], &size) ){
1459 const char *zName = blob_str(&xfer.aToken[1]);
1460 Blob content;
@@ -1494,11 +1495,11 @@
1494 }else
1495
1496
1497 /* private
1498 **
1499 ** This card indicates that the next "file" or "cfile" will contain
1500 ** private content.
1501 */
1502 if( blob_eq(&xfer.aToken[0], "private") ){
1503 if( !g.perm.Private ){
1504 server_private_xfer_not_authorized();
@@ -1515,10 +1516,12 @@
1515 ** ignored.
1516 */
1517 if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){
1518
1519 /* pragma send-private
 
 
1520 **
1521 ** If the user has the "x" privilege (which must be set explicitly -
1522 ** it is not automatic with "a" or "s") then this pragma causes
1523 ** private information to be pulled in addition to public records.
1524 */
@@ -1531,19 +1534,22 @@
1531 }
1532 }
1533
1534 /* pragma send-catalog
1535 **
1536 ** Send igot cards for all known artifacts.
 
 
1537 */
1538 if( blob_eq(&xfer.aToken[1], "send-catalog") ){
1539 xfer.resync = 0x7fffffff;
1540 }
1541
1542 /* pragma client-version VERSION
1543 **
1544 ** Let the server know what version of Fossil is running on the client.
 
1545 */
1546 if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){
1547 xfer.clientVersion = atoi(blob_str(&xfer.aToken[2]));
1548 }
1549
@@ -1570,11 +1576,11 @@
1570
1571 /* pragma ci-lock CHECKIN-HASH CLIENT-ID
1572 **
1573 ** The client wants to make non-branch commit against the check-in
1574 ** identified by CHECKIN-HASH. The server will remember this and
1575 ** subsequent ci-lock request from different clients will generate
1576 ** a ci-lock-fail pragma in the reply.
1577 */
1578 if( blob_eq(&xfer.aToken[1], "ci-lock")
1579 && xfer.nToken==4
1580 && blob_is_hname(&xfer.aToken[2])
@@ -1876,11 +1882,12 @@
1876 " SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;"
1877 );
1878 }
1879
1880 /*
1881 ** Always begin with a clone, pull, or push message
 
1882 */
1883 blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER);
1884 if( syncFlags & SYNC_CLONE ){
1885 blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
1886 syncFlags &= ~(SYNC_PUSH|SYNC_PULL);
@@ -1918,20 +1925,19 @@
1918 "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
1919 );
1920 manifest_crosslink_begin();
1921
1922
1923 /* Send back the most recently received cookie. Let the server
1924 ** figure out if this is a cookie that it cares about.
1925 */
1926 zCookie = db_get("cookie", 0);
1927 if( zCookie ){
1928 blob_appendf(&send, "cookie %s\n", zCookie);
1929 }
1930
1931 /* Generate gimme cards for phantoms and leaf cards
1932 ** for all leaves.
1933 */
1934 if( (syncFlags & SYNC_PULL)!=0
1935 || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1)
1936 ){
1937 request_phantoms(&xfer, mxPhantomReq);
@@ -1940,11 +1946,11 @@
1940 send_unsent(&xfer);
1941 nCardSent += send_unclustered(&xfer);
1942 if( syncFlags & SYNC_PRIVATE ) send_private(&xfer);
1943 }
1944
1945 /* Send configuration parameter requests. On a clone, delay sending
1946 ** this until the second cycle since the login card might fail on
1947 ** the first cycle.
1948 */
1949 if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){
1950 const char *zName;
@@ -1957,13 +1963,13 @@
1957 }
1958 origConfigRcvMask = configRcvMask;
1959 configRcvMask = 0;
1960 }
1961
1962 /* Send a request to sync unversioned files. On a clone, delay sending
1963 ** this until the second cycle since the login card might fail on
1964 ** the first cycle.
1965 */
1966 if( (syncFlags & SYNC_UNVERSIONED)!=0
1967 && ((syncFlags & SYNC_CLONE)==0 || nCycle>0)
1968 && !uvHashSent
1969 ){
@@ -1970,11 +1976,12 @@
1970 blob_appendf(&send, "pragma uv-hash %s\n", unversioned_content_hash(0));
1971 nCardSent++;
1972 uvHashSent = 1;
1973 }
1974
1975 /* Send configuration parameters being pushed */
 
1976 if( configSendMask ){
1977 if( zOpType==0 ) zOpType = "Push";
1978 nCardSent += configure_send_group(xfer.pOut, configSendMask, 0);
1979 configSendMask = 0;
1980 }
@@ -2030,11 +2037,11 @@
2030 zCkinLock = 0;
2031 }else if( zClientId ){
2032 blob_appendf(&send, "pragma ci-unlock %s\n", zClientId);
2033 }
2034
2035 /* Append randomness to the end of the message. This makes all
2036 ** messages unique so that that the login-card nonce will always
2037 ** be unique.
2038 */
2039 zRandomness = db_text(0, "SELECT hex(randomblob(20))");
2040 blob_appendf(&send, "# %s\n", zRandomness);
@@ -2132,30 +2139,30 @@
2132 }
2133
2134 /* file HASH SIZE \n CONTENT
2135 ** file HASH DELTASRC SIZE \n CONTENT
2136 **
2137 ** Receive a file transmitted from the server.
2138 */
2139 if( blob_eq(&xfer.aToken[0],"file") ){
2140 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
2141 nArtifactRcvd++;
2142 }else
2143
2144 /* cfile HASH USIZE CSIZE \n CONTENT
2145 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
2146 **
2147 ** Receive a compressed file transmitted from the server.
2148 */
2149 if( blob_eq(&xfer.aToken[0],"cfile") ){
2150 xfer_accept_compressed_file(&xfer, 0, 0);
2151 nArtifactRcvd++;
2152 }else
2153
2154 /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
2155 **
2156 ** Accept an unversioned file from the server.
2157 */
2158 if( blob_eq(&xfer.aToken[0], "uvfile") ){
2159 xfer_accept_unversioned_file(&xfer, 1);
2160 nArtifactRcvd++;
2161 nUvFileRcvd++;
@@ -2165,13 +2172,14 @@
2165 }
2166 }else
2167
2168 /* gimme HASH
2169 **
2170 ** Server is requesting a file. If the file is a manifest, assume
2171 ** that the server will also want to know all of the content files
2172 ** associated with the manifest and send those too.
 
2173 */
2174 if( blob_eq(&xfer.aToken[0], "gimme")
2175 && xfer.nToken==2
2176 && blob_is_hname(&xfer.aToken[1])
2177 ){
@@ -2284,11 +2292,11 @@
2284 }else
2285
2286 /* push SERVERCODE PRODUCTCODE
2287 **
2288 ** Should only happen in response to a clone. This message tells
2289 ** the client what product to use for the new database.
2290 */
2291 if( blob_eq(&xfer.aToken[0],"push")
2292 && xfer.nToken==3
2293 && (syncFlags & SYNC_CLONE)!=0
2294 && blob_is_hname(&xfer.aToken[2])
@@ -2301,11 +2309,11 @@
2301 nCardSent++;
2302 }else
2303
2304 /* config NAME SIZE \n CONTENT
2305 **
2306 ** Receive a configuration value from the server.
2307 **
2308 ** The received configuration setting is silently ignored if it was
2309 ** not requested by a prior "reqconfig" sent from client to server.
2310 */
2311 if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3
@@ -2323,11 +2331,11 @@
2323 }else
2324
2325
2326 /* cookie TEXT
2327 **
2328 ** The server might include a cookie in its reply. The client
2329 ** should remember this cookie and send it back to the server
2330 ** in its next query.
2331 **
2332 ** Each cookie received overwrites the prior cookie from the
2333 ** same server.
@@ -2337,12 +2345,12 @@
2337 }else
2338
2339
2340 /* private
2341 **
2342 ** This card indicates that the next "file" or "cfile" will contain
2343 ** private content.
2344 */
2345 if( blob_eq(&xfer.aToken[0], "private") ){
2346 xfer.nextIsPrivate = 1;
2347 }else
2348
@@ -2358,11 +2366,12 @@
2358 blob_is_int(&xfer.aToken[1], &cloneSeqno);
2359 }else
2360
2361 /* message MESSAGE
2362 **
2363 ** Print a message. Similar to "error" but does not stop processing.
 
2364 **
2365 ** If the "login failed" message is seen, clear the sync password prior
2366 ** to the next cycle.
2367 */
2368 if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){
@@ -2427,11 +2436,12 @@
2427 }
2428 }else
2429
2430 /* error MESSAGE
2431 **
2432 ** Report an error and abandon the sync session.
 
2433 **
2434 ** Except, when cloning we will sometimes get an error on the
2435 ** first message exchange because the project-code is unknown
2436 ** and so the login card on the request was invalid. The project-code
2437 ** is returned in the reply before the error card, so second and
2438
--- src/xfer.c
+++ src/xfer.c
@@ -1209,11 +1209,11 @@
1209 xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
1210
1211 /* file HASH SIZE \n CONTENT
1212 ** file HASH DELTASRC SIZE \n CONTENT
1213 **
1214 ** Server accepts a file from the client.
1215 */
1216 if( blob_eq(&xfer.aToken[0], "file") ){
1217 if( !isPush ){
1218 cgi_reset_content();
1219 @ error not\sauthorized\sto\swrite
@@ -1230,11 +1230,11 @@
1230 }else
1231
1232 /* cfile HASH USIZE CSIZE \n CONTENT
1233 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
1234 **
1235 ** Server accepts a compressed file from the client.
1236 */
1237 if( blob_eq(&xfer.aToken[0], "cfile") ){
1238 if( !isPush ){
1239 cgi_reset_content();
1240 @ error not\sauthorized\sto\swrite
@@ -1250,11 +1250,11 @@
1250 }
1251 }else
1252
1253 /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
1254 **
1255 ** Server accepts an unversioned file from the client.
1256 */
1257 if( blob_eq(&xfer.aToken[0], "uvfile") ){
1258 xfer_accept_unversioned_file(&xfer, g.perm.WrUnver);
1259 if( blob_size(&xfer.err) ){
1260 cgi_reset_content();
@@ -1264,11 +1264,11 @@
1264 }
1265 }else
1266
1267 /* gimme HASH
1268 **
1269 ** Client is requesting a file from the server. Send it.
1270 */
1271 if( blob_eq(&xfer.aToken[0], "gimme")
1272 && xfer.nToken==2
1273 && blob_is_hname(&xfer.aToken[1])
1274 ){
@@ -1281,11 +1281,11 @@
1281 }
1282 }else
1283
1284 /* uvgimme NAME
1285 **
1286 ** Client is requesting an unversioned file from the server. Send it.
1287 */
1288 if( blob_eq(&xfer.aToken[0], "uvgimme")
1289 && xfer.nToken==2
1290 && blob_is_filename(&xfer.aToken[1])
1291 ){
@@ -1408,11 +1408,12 @@
1408 @ push %s(db_get("server-code", "x")) %s(db_get("project-code", "x"))
1409 }else
1410
1411 /* login USER NONCE SIGNATURE
1412 **
1413 ** The client has sent login credentials to the server.
1414 ** Validate the login. This has to happen before anything else.
1415 ** The client can send multiple logins. Permissions are cumulative.
1416 */
1417 if( blob_eq(&xfer.aToken[0], "login")
1418 && xfer.nToken==4
1419 ){
@@ -1430,11 +1431,11 @@
1431 }
1432 }else
1433
1434 /* reqconfig NAME
1435 **
1436 ** Client is requesting a configuration value from the server
1437 */
1438 if( blob_eq(&xfer.aToken[0], "reqconfig")
1439 && xfer.nToken==2
1440 ){
1441 if( g.perm.Read ){
@@ -1449,12 +1450,12 @@
1450 }
1451 }else
1452
1453 /* config NAME SIZE \n CONTENT
1454 **
1455 ** Client has sent a configuration value to the server.
1456 ** This is only permitted for high-privilege users.
1457 */
1458 if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3
1459 && blob_is_int(&xfer.aToken[2], &size) ){
1460 const char *zName = blob_str(&xfer.aToken[1]);
1461 Blob content;
@@ -1494,11 +1495,11 @@
1495 }else
1496
1497
1498 /* private
1499 **
1500 ** The client card indicates that the next "file" or "cfile" will contain
1501 ** private content.
1502 */
1503 if( blob_eq(&xfer.aToken[0], "private") ){
1504 if( !g.perm.Private ){
1505 server_private_xfer_not_authorized();
@@ -1515,10 +1516,12 @@
1516 ** ignored.
1517 */
1518 if( blob_eq(&xfer.aToken[0], "pragma") && xfer.nToken>=2 ){
1519
1520 /* pragma send-private
1521 **
1522 ** The client is requesting private artifacts.
1523 **
1524 ** If the user has the "x" privilege (which must be set explicitly -
1525 ** it is not automatic with "a" or "s") then this pragma causes
1526 ** private information to be pulled in addition to public records.
1527 */
@@ -1531,19 +1534,22 @@
1534 }
1535 }
1536
1537 /* pragma send-catalog
1538 **
1539 ** The client wants to see igot cards for all known artifacts.
1540 ** This is used as part of "sync --verily" to help ensure that
1541 ** no artifacts have been missed on prior syncs.
1542 */
1543 if( blob_eq(&xfer.aToken[1], "send-catalog") ){
1544 xfer.resync = 0x7fffffff;
1545 }
1546
1547 /* pragma client-version VERSION
1548 **
1549 ** The client announces to the server what version of Fossil it
1550 ** is running.
1551 */
1552 if( xfer.nToken>=3 && blob_eq(&xfer.aToken[1], "client-version") ){
1553 xfer.clientVersion = atoi(blob_str(&xfer.aToken[2]));
1554 }
1555
@@ -1570,11 +1576,11 @@
1576
1577 /* pragma ci-lock CHECKIN-HASH CLIENT-ID
1578 **
1579 ** The client wants to make non-branch commit against the check-in
1580 ** identified by CHECKIN-HASH. The server will remember this and
1581 ** subsequent ci-lock requests from different clients will generate
1582 ** a ci-lock-fail pragma in the reply.
1583 */
1584 if( blob_eq(&xfer.aToken[1], "ci-lock")
1585 && xfer.nToken==4
1586 && blob_is_hname(&xfer.aToken[2])
@@ -1876,11 +1882,12 @@
1882 " SELECT name, 0 FROM unversioned WHERE hash IS NOT NULL;"
1883 );
1884 }
1885
1886 /*
1887 ** The request from the client always begin with a clone, pull,
1888 ** or push message.
1889 */
1890 blob_appendf(&send, "pragma client-version %d\n", RELEASE_VERSION_NUMBER);
1891 if( syncFlags & SYNC_CLONE ){
1892 blob_appendf(&send, "clone 3 %d\n", cloneSeqno);
1893 syncFlags &= ~(SYNC_PUSH|SYNC_PULL);
@@ -1918,20 +1925,19 @@
1925 "CREATE TEMP TABLE onremote(rid INTEGER PRIMARY KEY);"
1926 );
1927 manifest_crosslink_begin();
1928
1929
1930 /* Client sends the most recently received cookie back to the server.
1931 ** Let the server figure out if this is a cookie that it cares about.
1932 */
1933 zCookie = db_get("cookie", 0);
1934 if( zCookie ){
1935 blob_appendf(&send, "cookie %s\n", zCookie);
1936 }
1937
1938 /* Client sends gimme cards for phantoms
 
1939 */
1940 if( (syncFlags & SYNC_PULL)!=0
1941 || ((syncFlags & SYNC_CLONE)!=0 && cloneSeqno==1)
1942 ){
1943 request_phantoms(&xfer, mxPhantomReq);
@@ -1940,11 +1946,11 @@
1946 send_unsent(&xfer);
1947 nCardSent += send_unclustered(&xfer);
1948 if( syncFlags & SYNC_PRIVATE ) send_private(&xfer);
1949 }
1950
1951 /* Client sends configuration parameter requests. On a clone, delay sending
1952 ** this until the second cycle since the login card might fail on
1953 ** the first cycle.
1954 */
1955 if( configRcvMask && ((syncFlags & SYNC_CLONE)==0 || nCycle>0) ){
1956 const char *zName;
@@ -1957,13 +1963,13 @@
1963 }
1964 origConfigRcvMask = configRcvMask;
1965 configRcvMask = 0;
1966 }
1967
1968 /* Client sends a request to sync unversioned files.
1969 ** On a clone, delay sending this until the second cycle since
1970 ** the login card might fail on the first cycle.
1971 */
1972 if( (syncFlags & SYNC_UNVERSIONED)!=0
1973 && ((syncFlags & SYNC_CLONE)==0 || nCycle>0)
1974 && !uvHashSent
1975 ){
@@ -1970,11 +1976,12 @@
1976 blob_appendf(&send, "pragma uv-hash %s\n", unversioned_content_hash(0));
1977 nCardSent++;
1978 uvHashSent = 1;
1979 }
1980
1981 /* On a "fossil config push", the client send configuration parameters
1982 ** being pushed up to the server */
1983 if( configSendMask ){
1984 if( zOpType==0 ) zOpType = "Push";
1985 nCardSent += configure_send_group(xfer.pOut, configSendMask, 0);
1986 configSendMask = 0;
1987 }
@@ -2030,11 +2037,11 @@
2037 zCkinLock = 0;
2038 }else if( zClientId ){
2039 blob_appendf(&send, "pragma ci-unlock %s\n", zClientId);
2040 }
2041
2042 /* Append randomness to the end of the uplink message. This makes all
2043 ** messages unique so that that the login-card nonce will always
2044 ** be unique.
2045 */
2046 zRandomness = db_text(0, "SELECT hex(randomblob(20))");
2047 blob_appendf(&send, "# %s\n", zRandomness);
@@ -2132,30 +2139,30 @@
2139 }
2140
2141 /* file HASH SIZE \n CONTENT
2142 ** file HASH DELTASRC SIZE \n CONTENT
2143 **
2144 ** Client receives a file transmitted from the server.
2145 */
2146 if( blob_eq(&xfer.aToken[0],"file") ){
2147 xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
2148 nArtifactRcvd++;
2149 }else
2150
2151 /* cfile HASH USIZE CSIZE \n CONTENT
2152 ** cfile HASH DELTASRC USIZE CSIZE \n CONTENT
2153 **
2154 ** Client receives a compressed file transmitted from the server.
2155 */
2156 if( blob_eq(&xfer.aToken[0],"cfile") ){
2157 xfer_accept_compressed_file(&xfer, 0, 0);
2158 nArtifactRcvd++;
2159 }else
2160
2161 /* uvfile NAME MTIME HASH SIZE FLAGS \n CONTENT
2162 **
2163 ** Client accepts an unversioned file from the server.
2164 */
2165 if( blob_eq(&xfer.aToken[0], "uvfile") ){
2166 xfer_accept_unversioned_file(&xfer, 1);
2167 nArtifactRcvd++;
2168 nUvFileRcvd++;
@@ -2165,13 +2172,14 @@
2172 }
2173 }else
2174
2175 /* gimme HASH
2176 **
2177 ** Client receives an artifact request from the server.
2178 ** If the file is a manifest, assume that the server will also want
2179 ** to know all of the content artifacts associated with the manifest
2180 ** and send those too.
2181 */
2182 if( blob_eq(&xfer.aToken[0], "gimme")
2183 && xfer.nToken==2
2184 && blob_is_hname(&xfer.aToken[1])
2185 ){
@@ -2284,11 +2292,11 @@
2292 }else
2293
2294 /* push SERVERCODE PRODUCTCODE
2295 **
2296 ** Should only happen in response to a clone. This message tells
2297 ** the client what product code to use for the new database.
2298 */
2299 if( blob_eq(&xfer.aToken[0],"push")
2300 && xfer.nToken==3
2301 && (syncFlags & SYNC_CLONE)!=0
2302 && blob_is_hname(&xfer.aToken[2])
@@ -2301,11 +2309,11 @@
2309 nCardSent++;
2310 }else
2311
2312 /* config NAME SIZE \n CONTENT
2313 **
2314 ** Client receive a configuration value from the server.
2315 **
2316 ** The received configuration setting is silently ignored if it was
2317 ** not requested by a prior "reqconfig" sent from client to server.
2318 */
2319 if( blob_eq(&xfer.aToken[0],"config") && xfer.nToken==3
@@ -2323,11 +2331,11 @@
2331 }else
2332
2333
2334 /* cookie TEXT
2335 **
2336 ** The client reserves a cookie from the server. The client
2337 ** should remember this cookie and send it back to the server
2338 ** in its next query.
2339 **
2340 ** Each cookie received overwrites the prior cookie from the
2341 ** same server.
@@ -2337,12 +2345,12 @@
2345 }else
2346
2347
2348 /* private
2349 **
2350 ** The server tells the client that the next "file" or "cfile" will
2351 ** contain private content.
2352 */
2353 if( blob_eq(&xfer.aToken[0], "private") ){
2354 xfer.nextIsPrivate = 1;
2355 }else
2356
@@ -2358,11 +2366,12 @@
2366 blob_is_int(&xfer.aToken[1], &cloneSeqno);
2367 }else
2368
2369 /* message MESSAGE
2370 **
2371 ** A message is received from the server. Print it.
2372 ** Similar to "error" but does not stop processing.
2373 **
2374 ** If the "login failed" message is seen, clear the sync password prior
2375 ** to the next cycle.
2376 */
2377 if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){
@@ -2427,11 +2436,12 @@
2436 }
2437 }else
2438
2439 /* error MESSAGE
2440 **
2441 ** The server is reporting an error. The client will abandon
2442 ** the sync session.
2443 **
2444 ** Except, when cloning we will sometimes get an error on the
2445 ** first message exchange because the project-code is unknown
2446 ** and so the login card on the request was invalid. The project-code
2447 ** is returned in the reply before the error card, so second and
2448

Keyboard Shortcuts

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