From: Florin Coras Date: Sat, 15 Aug 2020 00:51:13 +0000 (-0700) Subject: session: ct init error handling X-Git-Tag: v21.01-rc0~100 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F28424%2F5;p=vpp.git session: ct init error handling Type: fix Signed-off-by: Florin Coras Change-Id: Ie70348406a2bfc156302687d2f5f98bc1a50c88f --- diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c index e3325932cfc..decff4ef68f 100644 --- a/src/vnet/session/application_local.c +++ b/src/vnet/session/application_local.c @@ -95,15 +95,16 @@ ct_session_connect_notify (session_t * ss) ct_connection_t *sct, *cct; app_worker_t *client_wrk; segment_manager_t *sm; + u32 ss_index, opaque; fifo_segment_t *seg; u64 segment_handle; int err = 0; session_t *cs; - u32 ss_index; ss_index = ss->session_index; sct = (ct_connection_t *) session_get_transport (ss); client_wrk = app_worker_get (sct->client_wrk); + opaque = sct->client_opaque; sm = segment_manager_get (ss->rx_fifo->segment_manager); seg = segment_manager_get_segment_w_lock (sm, ss->rx_fifo->segment_index); @@ -115,6 +116,7 @@ ct_session_connect_notify (session_t * ss) sct->client_wrk); segment_manager_segment_reader_unlock (sm); session_close (ss); + goto error; } else { @@ -143,15 +145,20 @@ ct_session_connect_notify (session_t * ss) /* This will allocate fifos for the session. They won't be used for * exchanging data but they will be used to close the connection if * the segment manager/worker is freed */ - if (app_worker_init_connected (client_wrk, cs)) + if ((err = app_worker_init_connected (client_wrk, cs))) { session_close (ss); - return -1; + session_free (cs); + goto error; } - if (app_worker_connect_notify (client_wrk, cs, err, sct->client_opaque)) + cs->session_state = SESSION_STATE_CONNECTING; + + if (app_worker_connect_notify (client_wrk, cs, err, opaque)) { session_close (ss); + segment_manager_dealloc_fifos (cs->rx_fifo, cs->tx_fifo); + session_free (cs); return -1; } @@ -159,6 +166,10 @@ ct_session_connect_notify (session_t * ss) cs->session_state = SESSION_STATE_READY; return 0; + +error: + app_worker_connect_notify (client_wrk, 0, err, opaque); + return -1; } static int @@ -475,6 +486,9 @@ ct_custom_tx (void *session, transport_send_params_t * sp) session_t *s = (session_t *) session; if (session_has_transport (s)) return 0; + /* As all other sessions, cut-throughs are scheduled by vpp for tx so let + * the scheduler's custom tx logic decide when to deschedule, i.e., after + * fifo is emptied. */ return ct_session_tx (s); }