Fossil SCM

begin work on ticket [bc0d0f5642eaf]: track success of (network) write operations and start bubbling that status up. To make it up to ultimately exit(EXIT_FAILURE) on errors, mkindex will need to be updated, too, as well as the signature from command implementing functions need to return int instead of void at some point. More to come.

martin.weber 2011-09-07 03:51 msw-hack
Commit a67e2683ed9cdb28f517784252b1d6927a8734e0
+4 -2
--- src/http.c
+++ src/http.c
@@ -190,12 +190,14 @@
190190
}
191191
192192
/*
193193
** Send the request to the server.
194194
*/
195
- transport_send(&hdr);
196
- transport_send(&payload);
195
+ if (transport_send(&hdr))
196
+ goto write_err;
197
+ if (transport_send(&payload))
198
+ goto write_err;
197199
blob_reset(&hdr);
198200
blob_reset(&payload);
199201
transport_flip();
200202
201203
/*
202204
--- src/http.c
+++ src/http.c
@@ -190,12 +190,14 @@
190 }
191
192 /*
193 ** Send the request to the server.
194 */
195 transport_send(&hdr);
196 transport_send(&payload);
 
 
197 blob_reset(&hdr);
198 blob_reset(&payload);
199 transport_flip();
200
201 /*
202
--- src/http.c
+++ src/http.c
@@ -190,12 +190,14 @@
190 }
191
192 /*
193 ** Send the request to the server.
194 */
195 if (transport_send(&hdr))
196 goto write_err;
197 if (transport_send(&payload))
198 goto write_err;
199 blob_reset(&hdr);
200 blob_reset(&payload);
201 transport_flip();
202
203 /*
204
--- src/http_transport.c
+++ src/http_transport.c
@@ -259,41 +259,48 @@
259259
}
260260
}
261261
262262
/*
263263
** Send content over the wire.
264
+** Returns whether sending was errant, i.e.,
265
+** the count of bytes written onto the wire does
266
+** not equal the size of the blob being sent.
264267
*/
265
-void transport_send(Blob *toSend){
268
+int transport_send(Blob *toSend){
266269
char *z = blob_buffer(toSend);
267270
int n = blob_size(toSend);
268
- transport.nSent += n;
271
+ size_t written = 0;
269272
if( g.urlIsSsh ){
270
- int sent;
271
- sent = fwrite(z, 1, n, sshOut);
273
+ written = fwrite(z, 1, n, sshOut);
272274
fflush(sshOut);
273
- /* printf("sent %d of %d bytes\n", sent, n); fflush(stdout); */
275
+ /* printf("sent %d of %d bytes\n", (unsigned long) written, n); fflush(stdout); */
274276
}else if( g.urlIsHttps ){
275277
#ifdef FOSSIL_ENABLE_SSL
276278
int sent;
277279
while( n>0 ){
278280
sent = ssl_send(0, z, n);
279281
/* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
280282
if( sent<=0 ) break;
281283
n -= sent;
284
+ written += sent;
282285
}
283286
#endif
284287
}else if( g.urlIsFile ){
285
- fwrite(z, 1, n, transport.pFile);
288
+ written = fwrite(z, 1, n, transport.pFile);
289
+ /* printf("written %d of %d bytes\n", (unsigned long) written, n); fflush(stdout); */
286290
}else{
287291
int sent;
288292
while( n>0 ){
289293
sent = socket_send(0, z, n);
290294
/* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
291295
if( sent<=0 ) break;
292296
n -= sent;
297
+ written += sent;
293298
}
294299
}
300
+ transport.nSent += written;
301
+ return (blob_size(toSend) != written);
295302
}
296303
297304
/*
298305
** This routine is called when the outbound message is complete and
299306
** it is time to being recieving a reply.
300307
--- src/http_transport.c
+++ src/http_transport.c
@@ -259,41 +259,48 @@
259 }
260 }
261
262 /*
263 ** Send content over the wire.
 
 
 
264 */
265 void transport_send(Blob *toSend){
266 char *z = blob_buffer(toSend);
267 int n = blob_size(toSend);
268 transport.nSent += n;
269 if( g.urlIsSsh ){
270 int sent;
271 sent = fwrite(z, 1, n, sshOut);
272 fflush(sshOut);
273 /* printf("sent %d of %d bytes\n", sent, n); fflush(stdout); */
274 }else if( g.urlIsHttps ){
275 #ifdef FOSSIL_ENABLE_SSL
276 int sent;
277 while( n>0 ){
278 sent = ssl_send(0, z, n);
279 /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
280 if( sent<=0 ) break;
281 n -= sent;
 
282 }
283 #endif
284 }else if( g.urlIsFile ){
285 fwrite(z, 1, n, transport.pFile);
 
286 }else{
287 int sent;
288 while( n>0 ){
289 sent = socket_send(0, z, n);
290 /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
291 if( sent<=0 ) break;
292 n -= sent;
 
293 }
294 }
 
 
295 }
296
297 /*
298 ** This routine is called when the outbound message is complete and
299 ** it is time to being recieving a reply.
300
--- src/http_transport.c
+++ src/http_transport.c
@@ -259,41 +259,48 @@
259 }
260 }
261
262 /*
263 ** Send content over the wire.
264 ** Returns whether sending was errant, i.e.,
265 ** the count of bytes written onto the wire does
266 ** not equal the size of the blob being sent.
267 */
268 int transport_send(Blob *toSend){
269 char *z = blob_buffer(toSend);
270 int n = blob_size(toSend);
271 size_t written = 0;
272 if( g.urlIsSsh ){
273 written = fwrite(z, 1, n, sshOut);
 
274 fflush(sshOut);
275 /* printf("sent %d of %d bytes\n", (unsigned long) written, n); fflush(stdout); */
276 }else if( g.urlIsHttps ){
277 #ifdef FOSSIL_ENABLE_SSL
278 int sent;
279 while( n>0 ){
280 sent = ssl_send(0, z, n);
281 /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
282 if( sent<=0 ) break;
283 n -= sent;
284 written += sent;
285 }
286 #endif
287 }else if( g.urlIsFile ){
288 written = fwrite(z, 1, n, transport.pFile);
289 /* printf("written %d of %d bytes\n", (unsigned long) written, n); fflush(stdout); */
290 }else{
291 int sent;
292 while( n>0 ){
293 sent = socket_send(0, z, n);
294 /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
295 if( sent<=0 ) break;
296 n -= sent;
297 written += sent;
298 }
299 }
300 transport.nSent += written;
301 return (blob_size(toSend) != written);
302 }
303
304 /*
305 ** This routine is called when the outbound message is complete and
306 ** it is time to being recieving a reply.
307
+1 -1
--- src/xfer.c
+++ src/xfer.c
@@ -1713,11 +1713,11 @@
17131713
** we have gone at least two rounds. Always go at least two rounds
17141714
** on a clone in order to be sure to retrieve the configuration
17151715
** information which is only sent on the second round.
17161716
*/
17171717
if( cloneSeqno<=0 && nCycle>1 ) go = 0;
1718
- };
1718
+ }
17191719
transport_stats(&nSent, &nRcvd, 1);
17201720
fossil_print("Total network traffic: %lld bytes sent, %lld bytes received\n",
17211721
nSent, nRcvd);
17221722
transport_close();
17231723
transport_global_shutdown();
17241724
--- src/xfer.c
+++ src/xfer.c
@@ -1713,11 +1713,11 @@
1713 ** we have gone at least two rounds. Always go at least two rounds
1714 ** on a clone in order to be sure to retrieve the configuration
1715 ** information which is only sent on the second round.
1716 */
1717 if( cloneSeqno<=0 && nCycle>1 ) go = 0;
1718 };
1719 transport_stats(&nSent, &nRcvd, 1);
1720 fossil_print("Total network traffic: %lld bytes sent, %lld bytes received\n",
1721 nSent, nRcvd);
1722 transport_close();
1723 transport_global_shutdown();
1724
--- src/xfer.c
+++ src/xfer.c
@@ -1713,11 +1713,11 @@
1713 ** we have gone at least two rounds. Always go at least two rounds
1714 ** on a clone in order to be sure to retrieve the configuration
1715 ** information which is only sent on the second round.
1716 */
1717 if( cloneSeqno<=0 && nCycle>1 ) go = 0;
1718 }
1719 transport_stats(&nSent, &nRcvd, 1);
1720 fossil_print("Total network traffic: %lld bytes sent, %lld bytes received\n",
1721 nSent, nRcvd);
1722 transport_close();
1723 transport_global_shutdown();
1724

Keyboard Shortcuts

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