+ /* Make sure we don't try to send anything more */
+ svm_fifo_dequeue_drop_all (s->server_tx_fifo);
+
+ switch (s->session_state)
+ {
+ case SESSION_STATE_TRANSPORT_CLOSING:
+ /* If transport finishes or times out before we get a reply
+ * from the app, mark transport as closed and wait for reply
+ * before removing the session. Cleanup session table in advance
+ * because transport will soon be closed and closed sessions
+ * are assumed to have been removed from the lookup table */
+ session_lookup_del_session (s);
+ s->session_state = SESSION_STATE_TRANSPORT_CLOSED;
+ break;
+ case SESSION_STATE_CLOSING:
+ case SESSION_STATE_CLOSED_WAITING:
+ /* Cleanup lookup table as transport needs to still be valid.
+ * Program transport close to ensure that all session events
+ * have been cleaned up. Once transport close is called, the
+ * session is just removed because both transport and app have
+ * confirmed the close*/
+ session_lookup_del_session (s);
+ s->session_state = SESSION_STATE_TRANSPORT_CLOSED;
+ session_program_transport_close (s);
+ break;
+ case SESSION_STATE_CLOSED:
+ case SESSION_STATE_ACCEPTING:
+ session_delete (s);
+ break;
+ default:
+ session_delete (s);
+ break;
+ }