From dfd27bc0f2bf8e95feec055de5e7a9b19a496bec Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Sat, 27 Nov 2021 10:45:55 -0800 Subject: session: postpone close notification if still accepting Acceping sessions might be rejected so the notification might not make sense. Type: improvement Signed-off-by: Florin Coras Change-Id: I3ababdce7c2cec62941d9722a9c06fa48ec547db --- src/vnet/session/session.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index f063548dcfe..f4a9e456454 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -1099,6 +1099,15 @@ session_transport_closing_notify (transport_connection_t * tc) s = session_get (tc->s_index, tc->thread_index); if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSING) return; + + /* Wait for reply from app before sending notification as the + * accept might be rejected */ + if (s->session_state == SESSION_STATE_ACCEPTING) + { + s->session_state = SESSION_STATE_TRANSPORT_CLOSING; + return; + } + s->session_state = SESSION_STATE_TRANSPORT_CLOSING; app_wrk = app_worker_get (s->app_wrk_index); app_worker_close_notify (app_wrk, s); @@ -1225,6 +1234,11 @@ session_transport_reset_notify (transport_connection_t * tc) svm_fifo_dequeue_drop_all (s->tx_fifo); if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSING) return; + if (s->session_state == SESSION_STATE_ACCEPTING) + { + s->session_state = SESSION_STATE_TRANSPORT_CLOSING; + return; + } s->session_state = SESSION_STATE_TRANSPORT_CLOSING; app_wrk = app_worker_get (s->app_wrk_index); app_worker_reset_notify (app_wrk, s); -- cgit 1.2.3-korg