Skip to content

Commit

Permalink
Ensure start time is set when reporting errors in fastping setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
brendonj committed Oct 30, 2019
1 parent 8a691a7 commit 30be353
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tests/fastping/fastping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 30be353

Please sign in to comment.