summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session/session.c')
-rw-r--r--src/vnet/session/session.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index be98e712e9b..ec6d7812f0b 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -599,7 +599,7 @@ session_stream_connect_notify (transport_connection_t * tc, u8 is_fail)
{
SESSION_DBG ("failed to notify app");
if (!is_fail)
- stream_session_disconnect (new_s);
+ stream_session_disconnect_transport (new_s);
}
else
{
@@ -924,14 +924,30 @@ stream_session_stop_listen (stream_session_t * s)
}
/**
- * Disconnect session and propagate to transport. This should eventually
+ * Initialize session disconnect.
+ *
+ * Request is always sent to session node to ensure that all outstanding
+ * requests are served before transport is notified.
+ */
+void
+stream_session_disconnect (stream_session_t * s)
+{
+ if (!s || s->session_state == SESSION_STATE_CLOSED)
+ return;
+ s->session_state = SESSION_STATE_CLOSED;
+ session_send_session_evt_to_thread (session_handle (s),
+ FIFO_EVENT_DISCONNECT, s->thread_index);
+}
+
+/**
+ * Notify transport the session can be disconnected. This should eventually
* result in a delete notification that allows us to cleanup session state.
* Called for both active/passive disconnects.
*
- * Should be called from the session's thread.
+ * Must be called from the session's thread.
*/
void
-stream_session_disconnect (stream_session_t * s)
+stream_session_disconnect_transport (stream_session_t * s)
{
s->session_state = SESSION_STATE_CLOSED;
tp_vfts[session_get_transport_proto (s)].close (s->connection_index,