From a797b4a19235be740c51bcb3bb6ec5de01915f46 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 7 Jun 2015 23:14:48 +0200 Subject: [PATCH] Fix receiving SPTPS data in sptps_speed and sptps_test. The sptps_receive_data() was changed in commit d237efd to only process one SPTPS record from a stream input. So now we have to put a loop around it to ensure we process everything. --- src/sptps_speed.c | 11 ++++++++--- src/sptps_test.c | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/sptps_speed.c b/src/sptps_speed.c index 4cb1221b..4d112dd7 100644 --- a/src/sptps_speed.c +++ b/src/sptps_speed.c @@ -47,11 +47,16 @@ static bool receive_record(void *handle, uint8_t type, const void *data, uint16_ } static void receive_data(sptps_t *sptps) { - char buf[4096]; + char buf[4096], *bufp = buf; int fd = *(int *)sptps->handle; size_t len = recv(fd, buf, sizeof buf, 0); - if(!sptps_receive_data(sptps, buf, len)) - abort(); + while(len) { + size_t done = sptps_receive_data(sptps, bufp, len); + if(!done) + abort(); + bufp += done; + len -= done; + } } struct timespec start; diff --git a/src/sptps_test.c b/src/sptps_test.c index f83307fe..9452ed1e 100644 --- a/src/sptps_test.c +++ b/src/sptps_test.c @@ -357,8 +357,19 @@ int main(int argc, char *argv[]) { fprintf(stderr, "Dropped.\n"); continue; } - if(!sptps_receive_data(&s, buf, len) && !datagram) - return 1; + char *bufp = buf; + while(len) { + size_t done = sptps_receive_data(&s, bufp, len); + if(!done) { + if(!datagram) + return 1; + } else { + break; + } + + bufp += done; + len -= done; + } } } -- 2.20.1