diff --git a/libqcdm/tests/ipv6pref.c b/libqcdm/tests/ipv6pref.c index f5bd71c4..bd0f08f8 100644 --- a/libqcdm/tests/ipv6pref.c +++ b/libqcdm/tests/ipv6pref.c @@ -95,16 +95,16 @@ qcdm_send (int fd, char *buf, size_t len) while (i < len) { errno = 0; - status = write (fd, &buf[i], 1); - if (status < 0) { - if (errno == EAGAIN) { + status = write (fd, &buf[i], len - i); + if (status <= 0) { + if (errno == EAGAIN || status == 0) { eagain_count--; if (eagain_count <= 0) return FALSE; } else assert (errno == 0); } else - i++; + i += status; usleep (1000); } diff --git a/libqcdm/tests/modepref.c b/libqcdm/tests/modepref.c index f8855161..25d3fa11 100644 --- a/libqcdm/tests/modepref.c +++ b/libqcdm/tests/modepref.c @@ -95,16 +95,16 @@ qcdm_send (int fd, char *buf, size_t len) while (i < len) { errno = 0; - status = write (fd, &buf[i], 1); - if (status < 0) { - if (errno == EAGAIN) { + status = write (fd, &buf[i], len - i); + if (status <= 0) { + if (errno == EAGAIN || status == 0) { eagain_count--; if (eagain_count <= 0) return FALSE; } else assert (errno == 0); } else - i++; + i += status; usleep (1000); } diff --git a/libqcdm/tests/reset.c b/libqcdm/tests/reset.c index 079ee386..e4508e43 100644 --- a/libqcdm/tests/reset.c +++ b/libqcdm/tests/reset.c @@ -96,16 +96,16 @@ qcdm_send (int fd, char *buf, size_t len) while (i < len) { errno = 0; - status = write (fd, &buf[i], 1); - if (status < 0) { - if (errno == EAGAIN) { + status = write (fd, &buf[i], len - i); + if (status <= 0) { + if (errno == EAGAIN || status == 0) { eagain_count--; if (eagain_count <= 0) return FALSE; } else assert (errno == 0); } else - i++; + i += status; usleep (1000); }