aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vnet/session/application_local.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c
index 8c17a15de53..05b946e40b8 100644
--- a/src/vnet/session/application_local.c
+++ b/src/vnet/session/application_local.c
@@ -322,6 +322,13 @@ done:
clib_rwlock_writer_unlock (&cm->app_segs_lock);
}
+static void
+ct_session_force_disconnect_server (ct_connection_t *sct)
+{
+ sct->peer_index = ~0;
+ session_transport_closing_notify (&sct->connection);
+}
+
int
ct_session_connect_notify (session_t *ss, session_error_t err)
{
@@ -341,9 +348,7 @@ ct_session_connect_notify (session_t *ss, session_error_t err)
/* Client closed while waiting for reply from server */
if (PREDICT_FALSE (!cct))
{
- session_transport_closing_notify (&sct->connection);
- session_transport_delete_notify (&sct->connection);
- ct_connection_free (sct);
+ ct_session_force_disconnect_server (sct);
return 0;
}
@@ -354,9 +359,11 @@ ct_session_connect_notify (session_t *ss, session_error_t err)
goto connect_error;
/*
- * Alloc client session
+ * Alloc client session, server session assumed to be established
*/
+ ASSERT (ss->session_state >= SESSION_STATE_READY);
+
cs = session_alloc (thread_index);
ss = session_get (ss_index, thread_index);
cs->session_type = ss->session_type;
@@ -372,7 +379,7 @@ ct_session_connect_notify (session_t *ss, session_error_t err)
if ((err = app_worker_init_connected (client_wrk, cs)))
{
session_free (cs);
- session_close (ss);
+ ct_session_force_disconnect_server (sct);
err = SESSION_E_ALLOC;
goto connect_error;
}
@@ -383,7 +390,7 @@ ct_session_connect_notify (session_t *ss, session_error_t err)
{
segment_manager_dealloc_fifos (cs->rx_fifo, cs->tx_fifo);
session_free (cs);
- session_close (ss);
+ ct_session_force_disconnect_server (sct);
goto cleanup_client;
}
@@ -398,8 +405,6 @@ connect_error:
cleanup_client:
- sct->peer_index = ~0;
-
if (cct->client_rx_fifo)
ct_session_dealloc_fifos (cct, cct->client_rx_fifo, cct->client_tx_fifo);
ct_connection_free (cct);
@@ -1068,6 +1073,7 @@ ct_session_close (u32 ct_index, u32 thread_index)
if (peer_ct->flags & CT_CONN_F_HALF_OPEN)
{
ct_session_connect_notify (s, SESSION_E_REFUSED);
+ ct->peer_index = ~0;
}
else if (peer_ct->c_s_index != ~0)
{