diff options
author | okir@lst.de <okir@lst.de> | 2007-06-18 18:46:33 -0500 |
---|---|---|
committer | Mike Christie <michaelc@cs.wisc.edu> | 2007-06-18 18:46:33 -0500 |
commit | 7b419dd4be66c236ba60d8a1cefa16bd985d1c11 (patch) | |
tree | f72f7a93928dff3d83c6649279aa526ba35f65ea /usr/mgmt_ipc.c | |
parent | 846dd89195bc416c4d40acae35ca54f9377950b9 (diff) | |
download | open-iscsi-7b419dd4be66c236ba60d8a1cefa16bd985d1c11.tar.gz |
mgmt_ipc_getstat should use session_find_by_sid
This patch changes mgmt_ipc_session_getstats by replacing
a home-made find loop with a call to session_find_by_sid
doing the same thing.
Signed-off-by: olaf.kirch@oracle.com
Diffstat (limited to 'usr/mgmt_ipc.c')
-rw-r--r-- | usr/mgmt_ipc.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c index 0e9f6dc..c872b12 100644 --- a/usr/mgmt_ipc.c +++ b/usr/mgmt_ipc.c @@ -103,32 +103,24 @@ static mgmt_ipc_err_e mgmt_ipc_session_getstats(queue_task_t *qtask) { int sid = qtask->req.u.session.sid; - struct iscsi_transport *t; iscsi_session_t *session; + int rc; - list_for_each_entry(t, &transports, list) { - list_for_each_entry(session, &t->sessions, list) { - if (session->id == sid) { - iscsiadm_rsp_t *rsp = &qtask->rsp; - int rc; - - rc = ipc->get_stats(session->t->handle, - session->id, session->conn[0].id, - (void*)&rsp->u.getstats, - MGMT_IPC_GETSTATS_BUF_MAX); - if (rc) { - log_error("get_stats(): IPC error %d " - "session [%02d]", rc, sid); - return MGMT_IPC_ERR_INTERNAL; - } - - mgmt_ipc_write_rsp(qtask, MGMT_IPC_OK); - return MGMT_IPC_OK; - } - } + if (!(session = session_find_by_sid(sid))) + return MGMT_IPC_ERR_NOT_FOUND; + + rc = ipc->get_stats(session->t->handle, + session->id, session->conn[0].id, + (void *)&qtask->rsp.u.getstats, + MGMT_IPC_GETSTATS_BUF_MAX); + if (rc) { + log_error("get_stats(): IPC error %d " + "session [%02d]", rc, sid); + return MGMT_IPC_ERR_INTERNAL; } - return MGMT_IPC_ERR_NOT_FOUND; + mgmt_ipc_write_rsp(qtask, MGMT_IPC_OK); + return MGMT_IPC_OK; } static mgmt_ipc_err_e |