Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Keep track of total network traffic for a sync and report the totals at the end of the sync. |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
79be9028ebdac88a1184179704d1a754 |
| User & Date: | drh 2009-08-12 14:41:32.000 |
Context
|
2009-08-12
| ||
| 17:35 | Rephrasing the text of the Login page. check-in: c15ec20d5a user: drh tags: trunk | |
| 14:41 | Keep track of total network traffic for a sync and report the totals at the end of the sync. check-in: 79be9028eb user: drh tags: trunk | |
| 14:27 | Fix an issue with "clone" on the client side: the client was requesting multiple copies of artifacts for which it held a delta with a phantom source. check-in: 7646ee13e3 user: drh tags: trunk | |
Changes
Changes to src/http_transport.c.
| ︙ | ︙ | |||
34 35 36 37 38 39 40 41 42 43 44 |
*/
static struct {
int isOpen; /* True when the transport layer is open */
char *pBuf; /* Buffer used to hold the reply */
int nAlloc; /* Space allocated for transportBuf[] */
int nUsed ; /* Space of transportBuf[] used */
int iCursor; /* Next unread by in transportBuf[] */
FILE *pFile; /* File I/O for FILE: */
char *zOutFile; /* Name of outbound file for FILE: */
char *zInFile; /* Name of inbound file for FILE: */
} transport = {
| > > | > > > > > > > > > > > > > | 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
*/
static struct {
int isOpen; /* True when the transport layer is open */
char *pBuf; /* Buffer used to hold the reply */
int nAlloc; /* Space allocated for transportBuf[] */
int nUsed ; /* Space of transportBuf[] used */
int iCursor; /* Next unread by in transportBuf[] */
int nSent; /* Number of bytes sent */
int nRcvd; /* Number of bytes received */
FILE *pFile; /* File I/O for FILE: */
char *zOutFile; /* Name of outbound file for FILE: */
char *zInFile; /* Name of inbound file for FILE: */
} transport = {
0, 0, 0, 0, 0, 0, 0
};
/*
** Return the current transport error message.
*/
const char *transport_errmsg(void){
return socket_errmsg();
}
/*
** Retrieve send/receive counts from the transport layer. If "resetFlag"
** is true, then reset the counts.
*/
void transport_stats(int *pnSent, int *pnRcvd, int resetFlag){
if( pnSent ) *pnSent = transport.nSent;
if( pnRcvd ) *pnRcvd = transport.nRcvd;
if( resetFlag ){
transport.nSent = 0;
transport.nRcvd = 0;
}
}
/*
** Open a connection to the server. The server is defined by the following
** global variables:
**
** g.urlName Name of the server. Ex: www.fossil-scm.org
** g.urlPort TCP/IP port. Ex: 80
|
| ︙ | ︙ | |||
118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
/*
** Send content over the wire.
*/
void transport_send(Blob *toSend){
char *z = blob_buffer(toSend);
int n = blob_size(toSend);
if( g.urlIsHttps ){
/* TBD */
}else if( g.urlIsFile ){
fwrite(z, 1, n, transport.pFile);
}else{
int sent;
while( n>0 ){
| > | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
/*
** Send content over the wire.
*/
void transport_send(Blob *toSend){
char *z = blob_buffer(toSend);
int n = blob_size(toSend);
transport.nSent += n;
if( g.urlIsHttps ){
/* TBD */
}else if( g.urlIsFile ){
fwrite(z, 1, n, transport.pFile);
}else{
int sent;
while( n>0 ){
|
| ︙ | ︙ | |||
200 201 202 203 204 205 206 |
}else if( g.urlIsFile ){
got = fread(zBuf, 1, N, transport.pFile);
}else{
got = socket_receive(0, zBuf, N);
/* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
}
if( got>0 ){
| | > | 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
}else if( g.urlIsFile ){
got = fread(zBuf, 1, N, transport.pFile);
}else{
got = socket_receive(0, zBuf, N);
/* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
}
if( got>0 ){
nByte += got;
transport.nRcvd += got;
}
}
return nByte;
}
/*
** Load up to N new bytes of content into the transport.pBuf buffer.
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
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 */
int mxPhantomReq = 200; /* Max number of phantoms to request per comm */
const char *zCookie; /* Server cookie */
Blob send; /* Text we are sending to the server */
Blob recv; /* Reply we got back from the server */
Xfer xfer; /* Transfer data */
const char *zSCode = db_get("server-code", "x");
const char *zPCode = db_get("project-code", 0);
socket_global_init();
memset(&xfer, 0, sizeof(xfer));
xfer.pIn = &recv;
xfer.pOut = &send;
xfer.mxSend = db_get_int("max-upload", 250000);
assert( pushFlag | pullFlag | cloneFlag | configRcvMask | configSendMask );
| > > | 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
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 */
int mxPhantomReq = 200; /* Max number of phantoms to request per comm */
const char *zCookie; /* Server cookie */
int nSent, nRcvd; /* Bytes sent and received (after compression) */
Blob send; /* Text we are sending to the server */
Blob recv; /* Reply we got back from the server */
Xfer xfer; /* Transfer data */
const char *zSCode = db_get("server-code", "x");
const char *zPCode = db_get("project-code", 0);
transport_stats(0, 0, 1);
socket_global_init();
memset(&xfer, 0, sizeof(xfer));
xfer.pIn = &recv;
xfer.pOut = &send;
xfer.mxSend = db_get_int("max-upload", 250000);
assert( pushFlag | pullFlag | cloneFlag | configRcvMask | configSendMask );
|
| ︙ | ︙ | |||
955 956 957 958 959 960 961 |
zName = configure_next_name(configSendMask);
nCard++;
}
configSendMask = 0;
}
/* Append randomness to the end of the message */
| < < | 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 |
zName = configure_next_name(configSendMask);
nCard++;
}
configSendMask = 0;
}
/* Append randomness to the end of the message */
zRandomness = db_text(0, "SELECT hex(randomblob(20))");
blob_appendf(&send, "# %s\n", zRandomness);
free(zRandomness);
/* Exchange messages with the server */
nFileSend = xfer.nFileSent + xfer.nDeltaSent;
printf(zValueFormat, "Send:",
blob_size(&send), nCard+xfer.nGimmeSent+xfer.nIGotSent,
xfer.nFileSent, xfer.nDeltaSent);
nCard = 0;
|
| ︙ | ︙ | |||
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 |
/* If we have one or more files queued to send, then go
** another round
*/
if( xfer.nFileSent+xfer.nDeltaSent>0 ){
go = 1;
}
};
transport_close();
socket_global_shutdown();
db_multi_exec("DROP TABLE onremote");
db_end_transaction(0);
}
| > > > | 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 |
/* If we have one or more files queued to send, then go
** another round
*/
if( xfer.nFileSent+xfer.nDeltaSent>0 ){
go = 1;
}
};
transport_stats(&nSent, &nRcvd, 1);
printf("Total network traffic: %d bytes sent, %d bytes received\n",
nSent, nRcvd);
transport_close();
socket_global_shutdown();
db_multi_exec("DROP TABLE onremote");
db_end_transaction(0);
}
|