diff options
Diffstat (limited to '')
| -rw-r--r-- | src/usr.bin/openssl/s_time.c | 66 |
1 files changed, 25 insertions, 41 deletions
diff --git a/src/usr.bin/openssl/s_time.c b/src/usr.bin/openssl/s_time.c index 735e73f78c..8aa3d9fbea 100644 --- a/src/usr.bin/openssl/s_time.c +++ b/src/usr.bin/openssl/s_time.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: s_time.c,v 1.27 2018/08/18 16:51:33 cheloha Exp $ */ | 1 | /* $OpenBSD: s_time.c,v 1.28 2018/08/21 15:56:39 cheloha Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -90,7 +90,7 @@ | |||
| 90 | extern int verify_depth; | 90 | extern int verify_depth; |
| 91 | 91 | ||
| 92 | static void s_time_usage(void); | 92 | static void s_time_usage(void); |
| 93 | static int doConnection(SSL *); | 93 | static int run_test(SSL *); |
| 94 | static int benchmark(int); | 94 | static int benchmark(int); |
| 95 | 95 | ||
| 96 | static SSL_CTX *tm_ctx = NULL; | 96 | static SSL_CTX *tm_ctx = NULL; |
| @@ -343,19 +343,21 @@ s_time_main(int argc, char **argv) | |||
| 343 | } | 343 | } |
| 344 | 344 | ||
| 345 | /*********************************************************************** | 345 | /*********************************************************************** |
| 346 | * doConnection - make a connection | 346 | * run_test - make a connection, get a file, and shut down the connection |
| 347 | * | ||
| 347 | * Args: | 348 | * Args: |
| 348 | * scon = SSL connection | 349 | * scon = SSL connection |
| 349 | * Returns: | 350 | * Returns: |
| 350 | * 1 on success, 0 on error | 351 | * 1 on success, 0 on error |
| 351 | */ | 352 | */ |
| 352 | static int | 353 | static int |
| 353 | doConnection(SSL *scon) | 354 | run_test(SSL *scon) |
| 354 | { | 355 | { |
| 356 | char buf[1024 * 8]; | ||
| 355 | struct pollfd pfd[1]; | 357 | struct pollfd pfd[1]; |
| 356 | BIO *conn; | 358 | BIO *conn; |
| 357 | long verify_error; | 359 | long verify_error; |
| 358 | int i; | 360 | int i, retval; |
| 359 | 361 | ||
| 360 | if ((conn = BIO_new(BIO_s_connect())) == NULL) | 362 | if ((conn = BIO_new(BIO_s_connect())) == NULL) |
| 361 | return 0; | 363 | return 0; |
| @@ -383,6 +385,22 @@ doConnection(SSL *scon) | |||
| 383 | ERR_print_errors(bio_err); | 385 | ERR_print_errors(bio_err); |
| 384 | return 0; | 386 | return 0; |
| 385 | } | 387 | } |
| 388 | if (s_time_config.www_path != NULL) { | ||
| 389 | retval = snprintf(buf, sizeof buf, | ||
| 390 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); | ||
| 391 | if ((size_t)retval >= sizeof buf) { | ||
| 392 | fprintf(stderr, "URL too long\n"); | ||
| 393 | return 0; | ||
| 394 | } | ||
| 395 | SSL_write(scon, buf, strlen(buf)); | ||
| 396 | while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) | ||
| 397 | bytes_read += i; | ||
| 398 | } | ||
| 399 | if (s_time_config.no_shutdown) | ||
| 400 | SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | | ||
| 401 | SSL_RECEIVED_SHUTDOWN); | ||
| 402 | else | ||
| 403 | SSL_shutdown(scon); | ||
| 386 | return 1; | 404 | return 1; |
| 387 | } | 405 | } |
| 388 | 406 | ||
| @@ -394,32 +412,16 @@ benchmark(int reuse_session) | |||
| 394 | SSL *scon = NULL; | 412 | SSL *scon = NULL; |
| 395 | time_t finishtime; | 413 | time_t finishtime; |
| 396 | int ret = 1; | 414 | int ret = 1; |
| 397 | char buf[1024 * 8]; | ||
| 398 | int ver; | 415 | int ver; |
| 399 | 416 | ||
| 400 | if (reuse_session) { | 417 | if (reuse_session) { |
| 401 | /* Get an SSL object so we can reuse the session id */ | 418 | /* Get an SSL object so we can reuse the session id */ |
| 402 | if ((scon = SSL_new(tm_ctx)) == NULL) | 419 | if ((scon = SSL_new(tm_ctx)) == NULL) |
| 403 | goto end; | 420 | goto end; |
| 404 | if (!doConnection(scon)) { | 421 | if (!run_test(scon)) { |
| 405 | fprintf(stderr, "Unable to get connection\n"); | 422 | fprintf(stderr, "Unable to get connection\n"); |
| 406 | goto end; | 423 | goto end; |
| 407 | } | 424 | } |
| 408 | if (s_time_config.www_path != NULL) { | ||
| 409 | int retval = snprintf(buf, sizeof buf, | ||
| 410 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); | ||
| 411 | if ((size_t)retval >= sizeof buf) { | ||
| 412 | fprintf(stderr, "URL too long\n"); | ||
| 413 | goto end; | ||
| 414 | } | ||
| 415 | SSL_write(scon, buf, strlen(buf)); | ||
| 416 | while (SSL_read(scon, buf, sizeof(buf)) > 0); | ||
| 417 | } | ||
| 418 | if (s_time_config.no_shutdown) | ||
| 419 | SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | | ||
| 420 | SSL_RECEIVED_SHUTDOWN); | ||
| 421 | else | ||
| 422 | SSL_shutdown(scon); | ||
| 423 | printf("starting\n"); | 425 | printf("starting\n"); |
| 424 | } | 426 | } |
| 425 | 427 | ||
| @@ -438,26 +440,8 @@ benchmark(int reuse_session) | |||
| 438 | if ((scon = SSL_new(tm_ctx)) == NULL) | 440 | if ((scon = SSL_new(tm_ctx)) == NULL) |
| 439 | goto end; | 441 | goto end; |
| 440 | } | 442 | } |
| 441 | if (!doConnection(scon)) | 443 | if (!run_test(scon)) |
| 442 | goto end; | 444 | goto end; |
| 443 | |||
| 444 | if (s_time_config.www_path != NULL) { | ||
| 445 | int i, retval = snprintf(buf, sizeof buf, | ||
| 446 | "GET %s HTTP/1.0\r\n\r\n", s_time_config.www_path); | ||
| 447 | if ((size_t)retval >= sizeof buf) { | ||
| 448 | fprintf(stderr, "URL too long\n"); | ||
| 449 | goto end; | ||
| 450 | } | ||
| 451 | SSL_write(scon, buf, strlen(buf)); | ||
| 452 | while ((i = SSL_read(scon, buf, sizeof(buf))) > 0) | ||
| 453 | bytes_read += i; | ||
| 454 | } | ||
| 455 | if (s_time_config.no_shutdown) | ||
| 456 | SSL_set_shutdown(scon, SSL_SENT_SHUTDOWN | | ||
| 457 | SSL_RECEIVED_SHUTDOWN); | ||
| 458 | else | ||
| 459 | SSL_shutdown(scon); | ||
| 460 | |||
| 461 | nConn += 1; | 445 | nConn += 1; |
| 462 | if (SSL_session_reused(scon)) | 446 | if (SSL_session_reused(scon)) |
| 463 | ver = 'r'; | 447 | ver = 'r'; |
