- Loosly merge of IET r271: fix connection and session leak on connection preparation stages

- Cleanups



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@1645 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2010-04-21 22:17:43 +00:00
parent 835a346923
commit f025190b53
7 changed files with 21 additions and 5 deletions
+1 -1
View File
@@ -894,7 +894,7 @@ int __del_conn(struct iscsi_session *session, struct iscsi_kern_conn_info *info)
conn = conn_lookup(session, info->cid);
if (!conn) {
PRINT_ERROR("Connection %d not found", info->cid);
PRINT_WARNING("Connection %d not found", info->cid);
return err;
}
+3
View File
@@ -69,6 +69,9 @@ void conn_pass_to_kern(struct connection *conn, int fd)
err = kernel_conn_create(conn->tid, conn->sess->sid.id64, conn->cid,
conn->stat_sn, conn->exp_stat_sn, fd);
if (err == 0)
conn->passed_to_kern = 1;
/* We don't need to return err, because we are going to close conn anyway */
return;
}
+2 -2
View File
@@ -303,7 +303,7 @@ int kernel_conn_destroy(u32 tid, u64 sid, u32 cid)
if ((err = ioctl(ctrl_fd, DEL_CONN, &info)) < 0) {
err = -errno;
log_error("Can't destroy conn (errno %d, tid %u, sid 0x%"
log_debug(2, "Can't destroy conn (errno %d, tid %u, sid 0x%"
PRIx64 ", cid %u\n", errno, tid, sid, cid);
}
@@ -437,7 +437,7 @@ int kernel_session_destroy(u32 tid, u64 sid)
res = ioctl(ctrl_fd, DEL_SESSION, &info);
if (res < 0) {
res = -errno;
log_error("Can't destroy sess 0x%" PRIu64 " (tid %d): %s\n",
log_debug(2, "Can't destroy sess 0x%" PRIu64 " (tid %d): %s\n",
sid, tid, strerror(errno));
}
+1
View File
@@ -112,6 +112,7 @@ static int send_mgmt_cmd_res(u32 tid, u32 cookie, u32 req_cmd, int result,
res = ioctl(ctrl_fd, MGMT_CMD_CALLBACK, &cinfo);
if (res != 0) {
res = -errno;
log_error("Can't send mgmt reply (cookie %d, result %d, "
"res %d): %s\n", cookie, result, res, strerror(errno));
}
+11
View File
@@ -557,12 +557,23 @@ static void event_loop(void)
event_conn(conn, pollfd);
if (conn->state == STATE_CLOSE) {
struct session *sess = conn->sess;
log_debug(1, "closing conn %p", conn);
conn_free_pdu(conn);
close(pollfd->fd);
pollfd->fd = -1;
incoming[i] = NULL;
incoming_cnt--;
if (conn->passed_to_kern) {
kernel_conn_destroy(conn->tid,
conn->sess->sid.id64, conn->cid);
} else {
conn_free(conn);
log_debug(1, "conn %p freed (sess %p, empty %d)",
conn, sess, sess ? list_empty(&sess->conn_list) : -1);
if (sess && list_empty(&sess->conn_list))
session_free(sess);
}
}
}
}
+2
View File
@@ -70,6 +70,8 @@ struct connection {
int iostate;
int fd;
unsigned int passed_to_kern:1;
struct session *sess;
u32 tid;
+1 -2
View File
@@ -152,8 +152,7 @@ void session_free(struct session *session)
{
log_debug(1, "Freeing session sid %#"PRIx64, session->sid.id64);
if (!session->sid.id.tsih)
kernel_session_destroy(session->target->tid, session->sid.id64);
kernel_session_destroy(session->target->tid, session->sid.id64);
if (session->target) {
struct target *target = session->target;