From 30be35340a413e6074d3d575bb9ef9e3b0ceda9a Mon Sep 17 00:00:00 2001 From: Brendon Jones Date: Wed, 30 Oct 2019 14:29:15 +1300 Subject: [PATCH] Ensure start time is set when reporting errors in fastping setup. --- src/tests/fastping/fastping.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tests/fastping/fastping.c b/src/tests/fastping/fastping.c index 2c45c45..30e14f1 100644 --- a/src/tests/fastping/fastping.c +++ b/src/tests/fastping/fastping.c @@ -598,12 +598,13 @@ static amp_test_result_t* send_icmp_stream(struct addrinfo *dest, memset(&stop_time, 0, sizeof(struct timeval)); memset(&loss_timeout, 0, sizeof(struct timeval)); - if ( dest->ai_addr == NULL ) { - if ( gettimeofday(&start_time, NULL) != 0 ) { - Log(LOG_ERR, "Could not gettimeofday(), aborting test"); - exit(EXIT_FAILURE); - } + /* get the current time to use when reporting initial errors */ + if ( gettimeofday(&start_time, NULL) != 0 ) { + Log(LOG_ERR, "Could not gettimeofday(), aborting test"); + exit(EXIT_FAILURE); + } + if ( dest->ai_addr == NULL ) { return report_result(&start_time, dest, options, NULL, NULL); } @@ -648,6 +649,7 @@ static amp_test_result_t* send_icmp_stream(struct addrinfo *dest, /* generate the first packet of the run before we are ready to send it */ length = build_packet(dest->ai_family, packet, options->size, 0, pid, 0); + /* set the actual start time now after doing all the setup */ if ( gettimeofday(&start_time, NULL) != 0 ) { Log(LOG_ERR, "Could not gettimeofday(), aborting test"); exit(EXIT_FAILURE);