[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 3/6] char: Let writers know how much data was wri
From: |
Amit Shah |
Subject: |
[Qemu-devel] [PATCH v7 3/6] char: Let writers know how much data was written in case of errors |
Date: |
Wed, 5 May 2010 03:09:27 +0530 |
On writing errors, we just returned -1 even if some bytes were already
written out. Ensure we return the number of bytes written before we
return the error (on a subsequent call to qemu_chr_write()).
Signed-off-by: Amit Shah <address@hidden>
---
qemu-char.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index 76ad12c..decf687 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -507,6 +507,9 @@ int send_all(int fd, const void *buf, int len1)
while (len > 0) {
ret = send(fd, buf, len, 0);
if (ret < 0) {
+ if (len1 - len) {
+ return len1 - len;
+ }
errno = WSAGetLastError();
if (errno != WSAEWOULDBLOCK) {
return -1;
@@ -531,8 +534,15 @@ static int unix_write(int fd, const uint8_t *buf, int len1)
while (len > 0) {
ret = write(fd, buf, len);
if (ret < 0) {
- if (errno != EINTR && errno != EAGAIN)
+ if (errno == EINTR) {
+ continue;
+ }
+ if (len1 - len) {
+ return len1 - len;
+ }
+ if (errno != EAGAIN) {
return -1;
+ }
} else if (ret == 0) {
break;
} else {
--
1.6.2.5
- [Qemu-devel] [PATCH v7 0/6], Amit Shah, 2010/05/04
- [Qemu-devel] [PATCH v7 1/6] virtio-console: Factor out common init between console and generic ports, Amit Shah, 2010/05/04
- [Qemu-devel] [PATCH v7 2/6] char: Add a QemuChrHandlers struct to initialise chardev handlers, Amit Shah, 2010/05/04
- [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes, Anthony Liguori, 2010/05/05
- [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes, Amit Shah, 2010/05/05
- [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes, Paul Brook, 2010/05/05
- [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes, Anthony Liguori, 2010/05/05
- [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes, Paul Brook, 2010/05/05
- [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes, Gerd Hoffmann, 2010/05/05
- [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes, Anthony Liguori, 2010/05/05