diff options
author | Amit Shah <amit.shah@redhat.com> | 2013-02-11 11:18:08 +0530 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2013-02-11 11:40:58 +0530 |
commit | 12cdb5f01e4a5030e0f92985f25b08f4c06be914 (patch) | |
tree | 3a353edd8fca9b4962c703e2b3a402e1ffe02600 /auto-virtserial-guest.c | |
parent | 98b540e0dd209cfaa1c34dad22dcd88fdc03b0d2 (diff) | |
download | test-virtserial-12cdb5f01e4a5030e0f92985f25b08f4c06be914.tar.gz test-virtserial-12cdb5f01e4a5030e0f92985f25b08f4c06be914.tar.xz test-virtserial-12cdb5f01e4a5030e0f92985f25b08f4c06be914.zip |
auto-guest: don't return -EAGAIN for all saferead() callers
Similar to commit e694887f173b3c0548ff3c1383e3fe954ac62692 for
safewrite().
Some callers are interested in -EAGAIN return in nonblocking mode, like
the test that checks for nonblocking functionality.
For other tests, we should try to read from local storage again in case
of -EAGAIN.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Diffstat (limited to 'auto-virtserial-guest.c')
-rw-r--r-- | auto-virtserial-guest.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/auto-virtserial-guest.c b/auto-virtserial-guest.c index 9146c43..cfa90b7 100644 --- a/auto-virtserial-guest.c +++ b/auto-virtserial-guest.c @@ -91,7 +91,7 @@ static ssize_t safewrite(int fd, const void *buf, size_t count, bool eagain_ret) return count - len; } -static ssize_t saferead(int fd, void *buf, size_t count) +static ssize_t saferead(int fd, void *buf, size_t count, bool eagain_ret) { size_t ret, len; int flags; @@ -110,7 +110,7 @@ static ssize_t saferead(int fd, void *buf, size_t count) continue; if (errno == EAGAIN) { - if (nonblock) { + if (nonblock && eagain_ret) { return -EAGAIN; } else { continue; @@ -215,7 +215,7 @@ static int read_port(int nr) buf = malloc(g_length); if (!buf) return -ENOMEM; - ret = saferead(g_open_fds[nr], buf, g_length); + ret = saferead(g_open_fds[nr], buf, g_length, true); free(buf); return ret; } @@ -316,7 +316,7 @@ static int recv_bytestream(int val) if (!buf) return -ENOMEM; - while((ret = saferead(g_fd, buf, g_length)) > 0) { + while((ret = saferead(g_fd, buf, g_length, false)) > 0) { ret = safewrite(g_bigfile_fd, buf, ret, false); if (ret < 0) break; @@ -345,7 +345,7 @@ static int send_host_csum(int nr) if (!csum_fd) { return -errno; } - ret = saferead(csum_fd, buf, g_length); + ret = saferead(csum_fd, buf, g_length, false); close(csum_fd); if (ret > 0) @@ -371,7 +371,7 @@ static int send_bytestream(int val) if (!buf) return -ENOMEM; - while((ret = saferead(g_bigfile_fd, buf, g_length)) > 0) { + while((ret = saferead(g_bigfile_fd, buf, g_length, false)) > 0) { ret = safewrite(g_fd, buf, ret, false); if (ret < 0) break; @@ -401,7 +401,7 @@ static int send_guest_csum(int nr) if (!csum_fd) { return -errno; } - ret = saferead(csum_fd, buf, g_length); + ret = saferead(csum_fd, buf, g_length, false); close(csum_fd); if (ret > 0) @@ -420,7 +420,7 @@ static int check_sysfs(int nr) if (fd < 0) return -errno; - ret = saferead(fd, g_sysfs_name, 1024); + ret = saferead(fd, g_sysfs_name, 1024, false); if (ret < 0) goto out_close; ret = 0; @@ -632,7 +632,7 @@ back_to_open: if (!(pollfd[0].revents & POLLIN)) continue; - ret = saferead(cfd, &gpkt, sizeof(gpkt)); + ret = saferead(cfd, &gpkt, sizeof(gpkt), false); if (ret < sizeof(gpkt)) { /* * Out of sync with host. Close port and start over. |