Skip to content

Instantly share code, notes, and snippets.

@pdu pdu/iscsid_mgmt_ipc.c
Last active Dec 21, 2015

Embed
What would you like to do?
remove conn of iscsid
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
You can’t perform that action at this time.