Last active
December 21, 2015 06:39
-
-
Save pdu/6265563 to your computer and use it in GitHub Desktop.
remove conn of iscsid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static mgmt_ipc_err_e | |
mgmt_ipc_conn_remove(queue_task_t *qtask) | |
{ | |
int sid = -1, cid = -1; | |
iscsi_session_t *session; | |
iscsi_conn_t *conn; | |
int err = MGMT_IPC_OK; | |
sid = qtask->req.u.conn.sid; | |
cid = qtask->req.u.conn.cid; | |
session = session_find_by_sid(sid); | |
if (NULL == session) { | |
err = MGMT_IPC_ERR; | |
log_error("session not found,sid:%d cid:%d\n", | |
sid, cid); | |
goto out; | |
} | |
if (cid >= ISCSI_CONN_MAX) { | |
err = MGMT_IPC_ERR; | |
log_error("cid invalid,sid:%d cid:%d\n", | |
sid, cid); | |
goto out; | |
} | |
conn = &session->conn[cid]; | |
if (NULL == conn) { | |
err = MGMT_IPC_ERR; | |
log_error("conn not found,sid:%d cid:%d\n", | |
sid, cid); | |
goto out; | |
} | |
if (conn->socket_fd == -1) { | |
err = MGMT_IPC_ERR; | |
log_error("socket_fd:%d sid:%d cid:%d\n", | |
conn->socket_fd, sid, cid); | |
goto out; | |
} | |
// if (MGMT_IPC_OK != session_conn_shutdown(conn, NULL, MGMT_IPC_OK)) { | |
// err = MGMT_IPC_ERR; | |
// log_error("session_conn_shutdown error,socket_fd:%d sid:%d cid:%d\n", | |
// conn->socket_fd, sid, cid); | |
// goto out; | |
// } | |
if (ipc->stop_conn(session->t->handle, session->id, | |
conn->id, STOP_CONN_TERM)) { | |
err = MGMT_IPC_ERR_INTERNAL; | |
log_error("can't stop connection %d:%d (%d)", | |
session->id, conn->id, errno); | |
goto out; | |
} | |
if (0 != close(conn->socket_fd)) { | |
err = MGMT_IPC_ERR; | |
log_error("close socket error,errno:%d socket_fd:%d sid:%d cid:%d\n", | |
errno, conn->socket_fd, sid, cid); | |
goto out; | |
} | |
log_debug("close socket ok,socket_fd:%d sid:%d cid:%d\n", | |
conn->socket_fd, sid, cid); | |
conn->socket_fd = -1; | |
out: | |
mgmt_ipc_write_rsp(qtask, err); | |
return MGMT_IPC_OK; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment