[stgt] [PATCH] tgtadm: handle a partial response properly
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Wed Oct 22 03:40:17 CEST 2008
tgtadm could get partial responses from tgtd so need to handle such
properly. This fixes the following problem:
http://lists.wpkg.org/pipermail/stgt/2008-October/002397.html
Reported-by: Tomasz Chmielewski <mangoo at wpkg.org>
Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
usr/tgtadm.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/usr/tgtadm.c b/usr/tgtadm.c
index f7b4fd3..ce7eb24 100644
--- a/usr/tgtadm.c
+++ b/usr/tgtadm.c
@@ -199,10 +199,23 @@ static int ipc_mgmt_rsp(int fd)
struct tgtadm_rsp rsp;
int err, rest, len;
- err = read(fd, &rsp, sizeof(rsp));
+retry:
+ err = recv(fd, &rsp, sizeof(rsp), MSG_WAITALL);
if (err < 0) {
- eprintf("can't get the response, %m\n");
+ if (errno == EAGAIN)
+ goto retry;
+ else if (errno == EINTR)
+ eprintf("interrupted by a signal\n");
+ else
+ eprintf("can't get the response, %m\n");
+
return errno;
+ } else if (err == 0) {
+ eprintf("tgtd closed the socket\n");
+ return 0;
+ } else if (err != sizeof(rsp)) {
+ eprintf("a partial response\n");
+ return 0;
}
if (rsp.err != TGTADM_SUCCESS) {
--
1.5.5.GIT
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list