Overview
SHA1 Hash: | 0690aa18a4aa3dfb6f055d486d278590f715a2cc |
---|---|
Date: | 2009-11-11 14:59:09 |
User: | drh |
Comment: | Better error messages when "sync" fails due to server problems. Ticket bfb8427cdd5 |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/http.c from [488f99c0c0] to [2e97d8ac83].
@@ -180,11 +180,16 @@ closeConnection = 1; iLength = -1; while( (zLine = transport_receive_line())!=0 && zLine[0]!=0 ){ if( strncasecmp(zLine, "http/1.", 7)==0 ){ if( sscanf(zLine, "HTTP/1.%d %d", &iHttpVersion, &rc)!=2 ) goto write_err; - if( rc!=200 ) goto write_err; + if( rc!=200 ){ + int ii; + for(ii=7; zLine[ii] && zLine[ii]!=' '; ii++){} + printf("ERROR. server says: %s\n", &zLine[ii]); + goto write_err; + } if( iHttpVersion==0 ){ closeConnection = 1; }else{ closeConnection = 0; } @@ -204,11 +209,14 @@ } /* ** Extract the reply payload that follows the header */ - if( iLength<0 ) goto write_err; + if( iLength<0 ){ + printf("ERROR. Server did not reply\n"); + goto write_err; + } blob_zero(pReply); blob_resize(pReply, iLength); iLength = transport_receive(blob_buffer(pReply), iLength); blob_resize(pReply, iLength); if( g.fHttpTrace ){
Modified src/xfer.c from [b02eb5519c] to [002c451193].
@@ -922,11 +922,12 @@ int cloneFlag, /* True if this is a clone */ int configRcvMask, /* Receive these configuration items */ int configSendMask /* Send these configuration items */ ){ int go = 1; /* Loop until zero */ - int nCard = 0; /* Number of cards sent or received */ + int nCardSent = 0; /* Number of cards sent */ + int nCardRcvd = 0; /* Number of cards received */ int nCycle = 0; /* Number of round trips to the server */ int size; /* Size of a config value */ int nFileSend = 0; int origConfigRcvMask; /* Original value of configRcvMask */ int nFileRecv; /* Number of files received */ @@ -968,19 +969,19 @@ */ if( cloneFlag ){ blob_appendf(&send, "clone\n"); pushFlag = 0; pullFlag = 0; - nCard++; + nCardSent++; /* TBD: Request all transferable configuration values */ }else if( pullFlag ){ blob_appendf(&send, "pull %s %s\n", zSCode, zPCode); - nCard++; + nCardSent++; } if( pushFlag ){ blob_appendf(&send, "push %s %s\n", zSCode, zPCode); - nCard++; + nCardSent++; } manifest_crosslink_begin(); printf(zLabelFormat, "", "Bytes", "Cards", "Artifacts", "Deltas"); while( go ){ @@ -1001,21 +1002,21 @@ if( pullFlag || cloneFlag ){ request_phantoms(&xfer, mxPhantomReq); } if( pushFlag ){ send_unsent(&xfer); - nCard += send_unclustered(&xfer); + nCardSent += send_unclustered(&xfer); } /* Send configuration parameter requests */ if( configRcvMask ){ const char *zName; zName = configure_first_name(configRcvMask); while( zName ){ blob_appendf(&send, "reqconfig %s\n", zName); zName = configure_next_name(configRcvMask); - nCard++; + nCardSent++; } if( configRcvMask & (CONFIGSET_USER|CONFIGSET_TKT) ){ configure_prepare_to_receive(0); } configRcvMask = 0; @@ -1026,11 +1027,11 @@ const char *zName; zName = configure_first_name(configSendMask); while( zName ){ send_config_card(&xfer, zName); zName = configure_next_name(configSendMask); - nCard++; + nCardSent++; } configSendMask = 0; } /* Append randomness to the end of the message */ @@ -1039,13 +1040,14 @@ free(zRandomness); /* Exchange messages with the server */ nFileSend = xfer.nFileSent + xfer.nDeltaSent; printf(zValueFormat, "Send:", - blob_size(&send), nCard+xfer.nGimmeSent+xfer.nIGotSent, + blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent, xfer.nFileSent, xfer.nDeltaSent); - nCard = 0; + nCardSent = 0; + nCardRcvd = 0; xfer.nFileSent = 0; xfer.nDeltaSent = 0; xfer.nGimmeSent = 0; fflush(stdout); http_exchange(&send, &recv); @@ -1054,25 +1056,25 @@ /* Begin constructing the next message (which might never be ** sent) by beginning with the pull or push cards */ if( pullFlag ){ blob_appendf(&send, "pull %s %s\n", zSCode, zPCode); - nCard++; + nCardSent++; } if( pushFlag ){ blob_appendf(&send, "push %s %s\n", zSCode, zPCode); - nCard++; + nCardSent++; } /* Process the reply that came back from the server */ while( blob_line(&recv, &xfer.line) ){ if( blob_buffer(&xfer.line)[0]=='#' ){ continue; } xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken)); - nCard++; - printf("\r%d", nCard); + nCardRcvd++; + printf("\r%d", nCardRcvd); fflush(stdout); /* file UUID SIZE \n CONTENT ** file UUID DELTASRC SIZE \n CONTENT ** @@ -1138,11 +1140,11 @@ if( zPCode==0 ){ zPCode = mprintf("%b", &xfer.aToken[2]); db_set("project-code", zPCode, 0); } blob_appendf(&send, "clone\n"); - nCard++; + nCardSent++; }else /* config NAME SIZE \n CONTENT ** ** Receive a configuration value from the server. @@ -1178,11 +1180,11 @@ ** presumably the operator trusts the server. */ db_multi_exec("%s", blob_str(&content)); } } - nCard++; + nCardSent++; blob_reset(&content); blob_seek(xfer.pIn, 1, BLOB_SEEK_CUR); }else @@ -1204,11 +1206,11 @@ ** Print a message. Similar to "error" but does not stop processing */ if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){ char *zMsg = blob_terminate(&xfer.aToken[1]); defossilize(zMsg); - printf("Server says: %s\n", zMsg); + printf("\rServer says: %s\n", zMsg); }else /* error MESSAGE ** ** Report an error and abandon the sync session @@ -1215,10 +1217,11 @@ */ if( blob_eq(&xfer.aToken[0],"error") && xfer.nToken==2 ){ char *zMsg = blob_terminate(&xfer.aToken[1]); defossilize(zMsg); blob_appendf(&xfer.err, "server says: %s", zMsg); + printf("Server Error: %s\n", zMsg); }else /* Unknown message */ { if( blob_str(&xfer.aToken[0])[0]=='<' ){ @@ -1238,13 +1241,15 @@ } if( origConfigRcvMask & (CONFIGSET_TKT|CONFIGSET_USER) ){ configure_finalize_receive(); } origConfigRcvMask = 0; - printf(zValueFormat, "Received:", - blob_size(&recv), nCard, - xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); + if( nCardRcvd>0 ){ + printf(zValueFormat, "Received:", + blob_size(&recv), nCardRcvd, + xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile); + } blob_reset(&recv); nCycle++; go = 0; /* If we received one or more files on the previous exchange but @@ -1254,11 +1259,11 @@ if( (nFileRecv>0 || newPhantom) && db_exists("SELECT 1 FROM phantom") ){ go = 1; mxPhantomReq = nFileRecv*2; if( mxPhantomReq<200 ) mxPhantomReq = 200; } - nCard = 0; + nCardRcvd = 0; xfer.nFileRcvd = 0; xfer.nDeltaRcvd = 0; xfer.nDanglingFile = 0; /* If we have one or more files queued to send, then go