[PATCH 13/15] Return appropriate errors if "tgtadm --op delete --mode conn" fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Arne Redlich <arne.redlich@xxxxxxxxxxxxxx>
---
 usr/iscsi/conn.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/usr/iscsi/conn.c b/usr/iscsi/conn.c
index 56ba2c4..61b570e 100644
--- a/usr/iscsi/conn.c
+++ b/usr/iscsi/conn.c
@@ -27,6 +27,7 @@
 #include "iscsid.h"
 #include "tgtd.h"
 #include "util.h"
+#include "tgtadm_error.h"
 
 void conn_add_to_session(struct iscsi_connection *conn, struct iscsi_session *session)
 {
@@ -211,27 +212,30 @@ int conn_take_fd(struct iscsi_connection *conn)
 	return 0;
 }
 
+/* called by tgtadm */
 int conn_close_force(uint32_t tid, uint64_t sid, uint32_t cid)
 {
 	struct iscsi_target* target = NULL;
 	struct iscsi_session *session;
 	struct iscsi_connection *conn;
+	int sess_found = 0;
 
 	target = target_find_by_id(tid);
 	if (!target)
-		return 0;
+		return TGTADM_NO_TARGET;
 
 	list_for_each_entry(session, &target->sessions_list, slist) {
 		if (session->tsih == sid) {
+			sess_found = 1;
 			list_for_each_entry(conn, &session->conn_list, clist) {
 				if (conn->cid == cid) {
 					eprintf("close %" PRIx64 " %u\n", sid, cid);
 					conn_close(conn);
-					goto out;
+					return TGTADM_SUCCESS;
 				}
 			}
 		}
 	}
-out:
-	return 0;
+
+	return sess_found ? TGTADM_NO_CONNECTION : TGTADM_NO_SESSION;
 }
-- 
1.6.0.4



--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux