Fix receiving SPTPS data in sptps_speed and sptps_test.
[tinc] / src / sptps_speed.c
index 4cb1221..4d112dd 100644 (file)
@@ -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;