[stgt] [PATCH] add some error messages in the ipc failure path
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Wed Oct 22 03:40:18 CEST 2008
Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
usr/mgmt.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/usr/mgmt.c b/usr/mgmt.c
index eabfccb..5351b2c 100644
--- a/usr/mgmt.c
+++ b/usr/mgmt.c
@@ -417,7 +417,9 @@ static void mtask_handler(int fd, int events, void *data)
tgt_mgmt(mtask);
mtask->mtask_state =
MTASK_STATE_RSP_SEND;
- tgt_event_modify(fd, EPOLLOUT);
+ if (tgt_event_modify(fd, EPOLLOUT))
+ eprintf("failed to modify\n");
+
mtask->done = 0;
} else {
/* the pdu exists */
@@ -444,7 +446,9 @@ static void mtask_handler(int fd, int events, void *data)
if (mtask->done == req->len - (sizeof(*req))) {
tgt_mgmt(mtask);
mtask->mtask_state = MTASK_STATE_RSP_SEND;
- tgt_event_modify(fd, EPOLLOUT);
+ if (tgt_event_modify(fd, EPOLLOUT))
+ eprintf("failed to modify\n");
+
mtask->done = 0;
}
} else
@@ -497,16 +501,22 @@ static void mgmt_event_handler(int accept_fd, int events, void *data)
struct mgmt_task *mtask;
fd = ipc_accept(accept_fd);
- if (fd < 0)
+ if (fd < 0) {
+ eprintf("failed to accept a socket\n");
return;
+ }
err = ipc_perm(fd);
- if (err < 0)
+ if (err < 0) {
+ eprintf("permission error\n");
goto out;
+ }
err = set_non_blocking(fd);
- if (err)
+ if (err) {
+ eprintf("failed to set a socket non-blocking\n");
goto out;
+ }
mtask = zalloc(sizeof(*mtask));
if (!mtask) {
@@ -516,6 +526,7 @@ static void mgmt_event_handler(int accept_fd, int events, void *data)
mtask->buf = zalloc(BUFSIZE);
if (!mtask->buf) {
+ eprintf("can't allocate mtask buffer\n");
free(mtask);
goto out;
}
@@ -524,6 +535,7 @@ static void mgmt_event_handler(int accept_fd, int events, void *data)
mtask->mtask_state = MTASK_STATE_HDR_RECV;
err = tgt_event_add(fd, EPOLLIN, mtask_handler, mtask);
if (err) {
+ eprintf("failed to add a socket to epoll %d\n", fd);
free(mtask->buf);
free(mtask);
goto out;
--
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