Fossil SCM
Use retry logic for SSL read/write as described in the OpenSSL docs.
Commit
4abf607937fac8e00269c2ce8f067b868ef21ef6
Parent
85fc2e0a4801349…
1 file changed
+14
-6
+14
-6
| --- src/http_ssl.c | ||
| +++ src/http_ssl.c | ||
| @@ -452,15 +452,19 @@ | ||
| 452 | 452 | |
| 453 | 453 | /* |
| 454 | 454 | ** Send content out over the SSL connection. |
| 455 | 455 | */ |
| 456 | 456 | size_t ssl_send(void *NotUsed, void *pContent, size_t N){ |
| 457 | - size_t sent; | |
| 458 | 457 | size_t total = 0; |
| 459 | 458 | 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 | + } | |
| 462 | 466 | total += sent; |
| 463 | 467 | N -= sent; |
| 464 | 468 | pContent = (void*)&((char*)pContent)[sent]; |
| 465 | 469 | } |
| 466 | 470 | return total; |
| @@ -468,18 +472,22 @@ | ||
| 468 | 472 | |
| 469 | 473 | /* |
| 470 | 474 | ** Receive content back from the SSL connection. |
| 471 | 475 | */ |
| 472 | 476 | size_t ssl_receive(void *NotUsed, void *pContent, size_t N){ |
| 473 | - size_t got; | |
| 474 | 477 | size_t total = 0; |
| 475 | 478 | 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 | + } | |
| 478 | 486 | total += got; |
| 479 | 487 | N -= got; |
| 480 | 488 | pContent = (void*)&((char*)pContent)[got]; |
| 481 | 489 | } |
| 482 | 490 | return total; |
| 483 | 491 | } |
| 484 | 492 | |
| 485 | 493 | #endif /* FOSSIL_ENABLE_SSL */ |
| 486 | 494 |
| --- 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 |