From c7d6ce71d5d8928c78db69c2aaa510672adc6aa4 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Tue, 15 Apr 2014 15:03:41 +0930 Subject: [PATCH] Fix "mdp ping" to exit after pongs --- commandline.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/commandline.c b/commandline.c index c33e7fb3..57b9b01e 100644 --- a/commandline.c +++ b/commandline.c @@ -1160,13 +1160,13 @@ int app_mdp_ping(const struct cli_parsed *parsed, struct cli_context *context) /* Now look for replies until one second has passed, and print any replies with appropriate information as required */ time_ms_t now = gettime_ms(); - time_ms_t finish = now + ((tx_count < icount || icount==0)?interval_ms:timeout_ms); - for (; sigIntFlag==0 && now < finish; now = gettime_ms()) { - time_ms_t poll_timeout_ms = finish - gettime_ms(); + time_ms_t finish = now + ((icount == 0 || tx_count < icount) ? interval_ms : timeout_ms); + for (; sigIntFlag==0 && (icount == 0 || rx_count < icount) && now < finish; now = gettime_ms()) { + time_ms_t poll_timeout_ms = finish - now; if (mdp_poll(mdp_sockfd, poll_timeout_ms)<=0) continue; - + struct mdp_header mdp_recv_header; uint8_t recv_payload[12]; ssize_t len = mdp_recv(mdp_sockfd, &mdp_recv_header, recv_payload, sizeof(recv_payload));