Fossil SCM

There is some bug in the new HTTP transport layer. The easiest solution is to close the TCP connection after each round trip, which is what this check-in does.

drh 2009-04-24 18:40 trunk
Commit 767ae79c3dcc16ba9923a4bbc708c5a662729aca
+5
--- src/http.c
+++ src/http.c
@@ -214,11 +214,16 @@
214214
blob_uncompress(pReply, pReply);
215215
}
216216
217217
/*
218218
** Close the connection to the server if appropriate.
219
+ **
220
+ ** FIXME: There is some bug in the lower layers that prevents the
221
+ ** connection from remaining open. The easiest fix for now is to
222
+ ** simply close and restart the connection for each round-trip.
219223
*/
224
+ closeConnection = 1; /* FIX ME */
220225
if( closeConnection ){
221226
transport_close();
222227
}else{
223228
transport_rewind();
224229
}
225230
--- src/http.c
+++ src/http.c
@@ -214,11 +214,16 @@
214 blob_uncompress(pReply, pReply);
215 }
216
217 /*
218 ** Close the connection to the server if appropriate.
 
 
 
 
219 */
 
220 if( closeConnection ){
221 transport_close();
222 }else{
223 transport_rewind();
224 }
225
--- src/http.c
+++ src/http.c
@@ -214,11 +214,16 @@
214 blob_uncompress(pReply, pReply);
215 }
216
217 /*
218 ** Close the connection to the server if appropriate.
219 **
220 ** FIXME: There is some bug in the lower layers that prevents the
221 ** connection from remaining open. The easiest fix for now is to
222 ** simply close and restart the connection for each round-trip.
223 */
224 closeConnection = 1; /* FIX ME */
225 if( closeConnection ){
226 transport_close();
227 }else{
228 transport_rewind();
229 }
230
--- src/http_transport.c
+++ src/http_transport.c
@@ -128,10 +128,11 @@
128128
fwrite(z, 1, n, transport.pFile);
129129
}else{
130130
int sent;
131131
while( n>0 ){
132132
sent = socket_send(0, z, n);
133
+ /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
133134
if( sent<=0 ) break;
134135
n -= sent;
135136
}
136137
}
137138
}
@@ -173,10 +174,11 @@
173174
174175
onHand = transport.nUsed - transport.iCursor;
175176
if( onHand>0 ){
176177
int toMove = onHand;
177178
if( toMove>N ) toMove = N;
179
+ /* printf("bytes on hand: %d of %d\n", toMove, N); fflush(stdout); */
178180
memcpy(zBuf, &transport.pBuf[transport.iCursor], toMove);
179181
transport.iCursor += toMove;
180182
if( transport.iCursor>=transport.nUsed ){
181183
transport.nUsed = 0;
182184
transport.iCursor = 0;
@@ -192,10 +194,11 @@
192194
got = 0;
193195
}else if( g.urlIsFile ){
194196
got = fread(zBuf, 1, N, transport.pFile);
195197
}else{
196198
got = socket_receive(0, zBuf, N);
199
+ /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
197200
}
198201
if( got>0 ){
199202
nByte += got;
200203
}
201204
}
@@ -270,7 +273,8 @@
270273
}
271274
break;
272275
}
273276
i++;
274277
}
278
+ /* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */
275279
return &transport.pBuf[iStart];
276280
}
277281
--- src/http_transport.c
+++ src/http_transport.c
@@ -128,10 +128,11 @@
128 fwrite(z, 1, n, transport.pFile);
129 }else{
130 int sent;
131 while( n>0 ){
132 sent = socket_send(0, z, n);
 
133 if( sent<=0 ) break;
134 n -= sent;
135 }
136 }
137 }
@@ -173,10 +174,11 @@
173
174 onHand = transport.nUsed - transport.iCursor;
175 if( onHand>0 ){
176 int toMove = onHand;
177 if( toMove>N ) toMove = N;
 
178 memcpy(zBuf, &transport.pBuf[transport.iCursor], toMove);
179 transport.iCursor += toMove;
180 if( transport.iCursor>=transport.nUsed ){
181 transport.nUsed = 0;
182 transport.iCursor = 0;
@@ -192,10 +194,11 @@
192 got = 0;
193 }else if( g.urlIsFile ){
194 got = fread(zBuf, 1, N, transport.pFile);
195 }else{
196 got = socket_receive(0, zBuf, N);
 
197 }
198 if( got>0 ){
199 nByte += got;
200 }
201 }
@@ -270,7 +273,8 @@
270 }
271 break;
272 }
273 i++;
274 }
 
275 return &transport.pBuf[iStart];
276 }
277
--- src/http_transport.c
+++ src/http_transport.c
@@ -128,10 +128,11 @@
128 fwrite(z, 1, n, transport.pFile);
129 }else{
130 int sent;
131 while( n>0 ){
132 sent = socket_send(0, z, n);
133 /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
134 if( sent<=0 ) break;
135 n -= sent;
136 }
137 }
138 }
@@ -173,10 +174,11 @@
174
175 onHand = transport.nUsed - transport.iCursor;
176 if( onHand>0 ){
177 int toMove = onHand;
178 if( toMove>N ) toMove = N;
179 /* printf("bytes on hand: %d of %d\n", toMove, N); fflush(stdout); */
180 memcpy(zBuf, &transport.pBuf[transport.iCursor], toMove);
181 transport.iCursor += toMove;
182 if( transport.iCursor>=transport.nUsed ){
183 transport.nUsed = 0;
184 transport.iCursor = 0;
@@ -192,10 +194,11 @@
194 got = 0;
195 }else if( g.urlIsFile ){
196 got = fread(zBuf, 1, N, transport.pFile);
197 }else{
198 got = socket_receive(0, zBuf, N);
199 /* printf("received %d of %d bytes\n", got, N); fflush(stdout); */
200 }
201 if( got>0 ){
202 nByte += got;
203 }
204 }
@@ -270,7 +273,8 @@
273 }
274 break;
275 }
276 i++;
277 }
278 /* printf("Got line: [%s]\n", &transport.pBuf[iStart]); */
279 return &transport.pBuf[iStart];
280 }
281

Keyboard Shortcuts

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