diff options
author | Amit Shah <amit.shah@redhat.com> | 2010-08-26 09:07:15 +0530 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2010-08-26 09:43:58 +0530 |
commit | 875796bff9d5d1aea84648b1b634a6f374ad0c7f (patch) | |
tree | 9d2e4bf95546344087d5234e0ae94879e4a8f7d5 | |
parent | af6f49a6cf54cdf76531eba26e605a9a1503d185 (diff) | |
download | test-virtserial-875796bff9d5d1aea84648b1b634a6f374ad0c7f.tar.gz test-virtserial-875796bff9d5d1aea84648b1b634a6f374ad0c7f.tar.xz test-virtserial-875796bff9d5d1aea84648b1b634a6f374ad0c7f.zip |
auto-test-guest: make open, read, write, close safe for multiple opens
We used to store the 'active' file descriptor in g_fd, and all the file
operations used to be performed on this fd, which was stored after an
open call.
This restricted us to having a max. of one port open at a time for
operations.
Use the new g_open_fds[] array to get the fd for the read/write/close
calls, so that these basic operations can be performed on multiple open
ports.
This is useful for the multiple-port sigio test.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r-- | auto-virtserial-guest.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/auto-virtserial-guest.c b/auto-virtserial-guest.c index ce3e6e5..7e16282 100644 --- a/auto-virtserial-guest.c +++ b/auto-virtserial-guest.c @@ -208,7 +208,7 @@ static int read_port(int nr) buf = malloc(g_length); if (!buf) return -ENOMEM; - ret = saferead(g_fd, buf, g_length); + ret = saferead(g_open_fds[nr], buf, g_length); free(buf); return ret; } @@ -224,7 +224,7 @@ static int write_port(int nr) buf = malloc(g_length); if (!buf) return -ENOMEM; - ret = safewrite(g_fd, buf, g_length); + ret = safewrite(g_open_fds[nr], buf, g_length); free(buf); return ret; } @@ -233,7 +233,7 @@ static int close_port(int nr) { int ret; - ret = close(g_fd); + ret = close(g_open_fds[nr]); if (ret < 0) ret = -errno; g_length = 0; |