@@ -68,9 +68,9 @@
blob_delta_apply(&src, &content, &content);
blob_reset(&src);
}
sha1sum_blob(&content, &hash);
- if( !blob_eq_str(&aToken[1], blob_str(&content), -1) ){
+ if( !blob_eq_str(&aToken[1], blob_str(&hash), -1) ){
blob_appendf(pErr, "content does not match sha1 hash");
}
blob_reset(&hash);
rid = content_put(&content, 0);
@@ -129,10 +129,11 @@
/*
** Send all pending files.
*/
-static void send_all_pending(Blob *pOut){
+static int send_all_pending(Blob *pOut){
int sent = 0;
+ int nSent = 0;
int maxSize = db_get_int("http-msg-size", 1000000);
Stmt q;
#if 0
db_multi_exec(
@@ -161,8 +162,9 @@
while( db_step(&q)==SQLITE_ROW ){
int rid = db_column_int(&q, 0);
if( sent<maxSize ){
sent += send_file(rid, pOut);
+ nSent++;
}else{
char *zUuid = db_text(0,
"SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
if( zUuid ){
@@ -179,8 +181,9 @@
#if 0
db_multi_exec("DROP TABLE priority");
#endif
+ return nSent;
}
/*
@@ -481,8 +484,11 @@
int go = 1; /* Loop until zero */
int nToken;
const char *zSCode = db_get("server-code", "x");
const char *zPCode = db_get("project-code", 0);
+ int nSent = 0;
+ int nRcvd = 0;
+ int nCycle = 0;
Blob send; /* Text we are sending to the server */
Blob recv; /* Reply we got back from the server */
Blob line; /* A single line of the reply */
Blob aToken[5]; /* A tokenization of line */
@@ -534,9 +540,9 @@
}
if( pushFlag ){
/* Send the server any files that the server has requested */
- send_all_pending(&send);
+ nSent += send_all_pending(&send);
}
if( pullFlag || pushFlag ){
/* Always send our leaves */
@@ -552,8 +558,9 @@
db_finalize(&q);
}
/* Exchange messages with the server */
+ printf("Sending %d files to server\n", nSent);
http_exchange(&send, &recv);
blob_reset(&send);
/* Process the reply that came back from the server */
@@ -566,8 +573,9 @@
** Receive a file transmitted from the other side
*/
if( blob_eq(&aToken[0],"file") ){
xfer_accept_file(&recv, aToken, nToken, &errmsg);
+ nRcvd++;
}else
/* gimme UUID
**
@@ -619,17 +627,17 @@
/* push SERVERCODE PRODUCTCODE
**
** Should only happen in response to a clone.
*/
- if( blob_eq(&aToken[0],"push") && nToken==2 && cloneFlag
+ if( blob_eq(&aToken[0],"push") && nToken==3 && cloneFlag
&& blob_is_uuid(&aToken[1]) && blob_is_uuid(&aToken[2]) ){
if( blob_eq_str(&aToken[1], zSCode, -1) ){
fossil_fatal("server loop");
}
if( zPCode==0 ){
zPCode = mprintf("%b", &aToken[2]);
- db_set("product-code", zPCode);
+ db_set("project-code", zPCode);
}
cloneFlag = 0;
pullFlag = 1;
}else
@@ -654,8 +662,10 @@
}
blobarray_reset(aToken, nToken);
}
blob_reset(&recv);
+ printf("Received %d files from server\n", nRcvd);
+ nSent = nRcvd = 0;
};
http_close();
db_end_transaction(0);
db_multi_exec(