mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-25 07:51:28 +00:00
Patch from Stefan Hauser <st.hauser@googlemail.com> with some style changes fixing case when after a error
between sessions_count increment and the corresponding session creation, sessions_count is not decremented. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3353 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -578,6 +578,12 @@ static void event_loop(void)
|
||||
conn->sess->sid.id64,
|
||||
conn->cid);
|
||||
} else {
|
||||
/*
|
||||
* Check if session could not be established,
|
||||
* but sessions count was already incremented
|
||||
*/
|
||||
if (!sess && conn->sessions_count_incremented)
|
||||
conn->target->sessions_count--;
|
||||
conn_free(conn);
|
||||
log_debug(1, "conn %p freed (sess %p, empty %d)",
|
||||
conn, sess,
|
||||
|
||||
@@ -525,6 +525,8 @@ static void login_start(struct connection *conn)
|
||||
return;
|
||||
}
|
||||
|
||||
conn->target = target;
|
||||
|
||||
/* We may "leak" here if we have an iSCSI event on the wrong time */
|
||||
if (!iscsi_enabled) {
|
||||
log_info("Connect from %s to disabled iSCSI-SCST refused",
|
||||
@@ -580,13 +582,15 @@ static void login_start(struct connection *conn)
|
||||
rc = login_check_reinstatement(conn);
|
||||
if (rc < 0)
|
||||
return;
|
||||
else if (rc == ISCSI_SESS_REINSTATEMENT)
|
||||
target->sessions_count++;
|
||||
else if (rc != ISCSI_CONN_REINSTATEMENT) {
|
||||
if ((target->target_params[key_max_sessions] == 0) ||
|
||||
(target->sessions_count < target->target_params[key_max_sessions]))
|
||||
else if (rc == ISCSI_SESS_REINSTATEMENT) {
|
||||
target->sessions_count++;
|
||||
else {
|
||||
conn->sessions_count_incremented = 1;
|
||||
} else if (rc != ISCSI_CONN_REINSTATEMENT) {
|
||||
if ((target->target_params[key_max_sessions] == 0) ||
|
||||
(target->sessions_count < target->target_params[key_max_sessions])) {
|
||||
target->sessions_count++;
|
||||
conn->sessions_count_incremented = 1;
|
||||
} else {
|
||||
log_warning("Initiator %s not allowed to connect to "
|
||||
"target %s - max sessions limit "
|
||||
"reached (%d)", name, target_name,
|
||||
|
||||
@@ -82,7 +82,9 @@ struct connection {
|
||||
int fd;
|
||||
|
||||
unsigned int passed_to_kern:1;
|
||||
unsigned int sessions_count_incremented:1;
|
||||
|
||||
struct target *target;
|
||||
struct session *sess;
|
||||
|
||||
u32 tid;
|
||||
|
||||
Reference in New Issue
Block a user