session: only notify server on ct connect failure
Type: fix
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ifcb631ed2913e5f4fc318238de9100286a7990d2
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c
index 8c17a15..05b946e 100644
--- a/src/vnet/session/application_local.c
+++ b/src/vnet/session/application_local.c
@@ -322,6 +322,13 @@
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 @@
/* 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 @@
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 @@
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 @@
{
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 @@
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 @@
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)
{