Fossil SCM

Use retry logic for SSL read/write as described in the OpenSSL docs.

mistachkin 2016-04-19 17:44 trunk merge
Commit 4abf607937fac8e00269c2ce8f067b868ef21ef6
1 file changed +14 -6
+14 -6
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -452,15 +452,19 @@
452452
453453
/*
454454
** Send content out over the SSL connection.
455455
*/
456456
size_t ssl_send(void *NotUsed, void *pContent, size_t N){
457
- size_t sent;
458457
size_t total = 0;
459458
while( N>0 ){
460
- sent = BIO_write(iBio, pContent, N);
461
- if( sent<=0 ) break;
459
+ int sent = BIO_write(iBio, pContent, N);
460
+ if( sent<=0 ){
461
+ if( BIO_should_retry(iBio) ){
462
+ continue;
463
+ }
464
+ break;
465
+ }
462466
total += sent;
463467
N -= sent;
464468
pContent = (void*)&((char*)pContent)[sent];
465469
}
466470
return total;
@@ -468,18 +472,22 @@
468472
469473
/*
470474
** Receive content back from the SSL connection.
471475
*/
472476
size_t ssl_receive(void *NotUsed, void *pContent, size_t N){
473
- size_t got;
474477
size_t total = 0;
475478
while( N>0 ){
476
- got = BIO_read(iBio, pContent, N);
477
- if( got<=0 ) break;
479
+ int got = BIO_read(iBio, pContent, N);
480
+ if( got<=0 ){
481
+ if( BIO_should_retry(iBio) ){
482
+ continue;
483
+ }
484
+ break;
485
+ }
478486
total += got;
479487
N -= got;
480488
pContent = (void*)&((char*)pContent)[got];
481489
}
482490
return total;
483491
}
484492
485493
#endif /* FOSSIL_ENABLE_SSL */
486494
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -452,15 +452,19 @@
452
453 /*
454 ** Send content out over the SSL connection.
455 */
456 size_t ssl_send(void *NotUsed, void *pContent, size_t N){
457 size_t sent;
458 size_t total = 0;
459 while( N>0 ){
460 sent = BIO_write(iBio, pContent, N);
461 if( sent<=0 ) break;
 
 
 
 
 
462 total += sent;
463 N -= sent;
464 pContent = (void*)&((char*)pContent)[sent];
465 }
466 return total;
@@ -468,18 +472,22 @@
468
469 /*
470 ** Receive content back from the SSL connection.
471 */
472 size_t ssl_receive(void *NotUsed, void *pContent, size_t N){
473 size_t got;
474 size_t total = 0;
475 while( N>0 ){
476 got = BIO_read(iBio, pContent, N);
477 if( got<=0 ) break;
 
 
 
 
 
478 total += got;
479 N -= got;
480 pContent = (void*)&((char*)pContent)[got];
481 }
482 return total;
483 }
484
485 #endif /* FOSSIL_ENABLE_SSL */
486
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -452,15 +452,19 @@
452
453 /*
454 ** Send content out over the SSL connection.
455 */
456 size_t ssl_send(void *NotUsed, void *pContent, size_t N){
 
457 size_t total = 0;
458 while( N>0 ){
459 int sent = BIO_write(iBio, pContent, N);
460 if( sent<=0 ){
461 if( BIO_should_retry(iBio) ){
462 continue;
463 }
464 break;
465 }
466 total += sent;
467 N -= sent;
468 pContent = (void*)&((char*)pContent)[sent];
469 }
470 return total;
@@ -468,18 +472,22 @@
472
473 /*
474 ** Receive content back from the SSL connection.
475 */
476 size_t ssl_receive(void *NotUsed, void *pContent, size_t N){
 
477 size_t total = 0;
478 while( N>0 ){
479 int got = BIO_read(iBio, pContent, N);
480 if( got<=0 ){
481 if( BIO_should_retry(iBio) ){
482 continue;
483 }
484 break;
485 }
486 total += got;
487 N -= got;
488 pContent = (void*)&((char*)pContent)[got];
489 }
490 return total;
491 }
492
493 #endif /* FOSSIL_ENABLE_SSL */
494

Keyboard Shortcuts

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