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.
This commit is contained in:
parent
d8d1ab4ee1
commit
a797b4a192
2 changed files with 21 additions and 5 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue