X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsession%2Fsession_node.c;h=281622bcc9b047301bedad0e729f49c1e44f42ec;hb=326b81e30e63a8296df51d85e6514356cd737225;hp=119cdd812ad8d907f8750faf8df17253de6fbab7;hpb=ab2f6dbf9f7b7164a9810f4c80c8abf8463e42ad;p=vpp.git diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c index 119cdd812ad..281622bcc9b 100644 --- a/src/vnet/session/session_node.c +++ b/src/vnet/session/session_node.c @@ -29,6 +29,7 @@ session_mq_accepted_reply_handler (void *data) { session_accepted_reply_msg_t *mp = (session_accepted_reply_msg_t *) data; vnet_disconnect_args_t _a = { 0 }, *a = &_a; + app_worker_t *app_wrk; local_session_t *ls; stream_session_t *s; @@ -43,8 +44,6 @@ session_mq_accepted_reply_handler (void *data) if (session_handle_is_local (mp->handle)) { - app_worker_t *app_wrk; - application_t *app; ls = application_get_local_session_from_handle (mp->handle); if (!ls) { @@ -52,8 +51,7 @@ session_mq_accepted_reply_handler (void *data) return; } app_wrk = app_worker_get (ls->app_wrk_index); - app = application_get (app_wrk->app_index); - if (app->app_index != mp->context) + if (app_wrk->app_index != mp->context) { clib_warning ("server %u doesn't own local handle 0x%lx", mp->context, mp->handle); @@ -71,18 +69,15 @@ session_mq_accepted_reply_handler (void *data) clib_warning ("session doesn't exist"); return; } - if (s->app_wrk_index != mp->context) + app_wrk = app_worker_get (s->app_wrk_index); + if (app_wrk->app_index != mp->context) { clib_warning ("app doesn't own session"); return; } s->session_state = SESSION_STATE_READY; if (!svm_fifo_is_empty (s->server_rx_fifo)) - { - app_worker_t *app; - app = app_worker_get (s->app_wrk_index); - app_worker_send_event (app, s, FIFO_EVENT_APP_RX); - } + app_worker_lock_and_send_event (app_wrk, s, FIFO_EVENT_APP_RX); } } @@ -735,6 +730,8 @@ session_tx_fifo_dequeue_internal (vlib_main_t * vm, stream_session_t * s, int *n_tx_pkts) { application_t *app; + if (PREDICT_FALSE (s->session_state == SESSION_STATE_CLOSED)) + return 0; app = application_get (s->t_app_index); svm_fifo_unset_event (s->server_tx_fifo); return app->cb_fns.builtin_app_tx_callback (s); @@ -822,7 +819,7 @@ skip_dequeue: { stream_session_t *s; /* $$$ prefetch 1 ahead maybe */ session_event_t *e; - u8 is_full; + u8 want_tx_evt; e = &fifo_events[i]; switch (e->event_type) @@ -838,21 +835,22 @@ skip_dequeue: s = session_event_get_session (e, thread_index); if (PREDICT_FALSE (!s)) { - clib_warning ("It's dead, Jim!"); + clib_warning ("session was freed!"); continue; } - is_full = svm_fifo_is_full (s->server_tx_fifo); + want_tx_evt = svm_fifo_want_tx_evt (s->server_tx_fifo); /* Spray packets in per session type frames, since they go to * different nodes */ rv = (smm->session_tx_fns[s->session_type]) (vm, node, e, s, &n_tx_packets); if (PREDICT_TRUE (rv == SESSION_TX_OK)) { - /* Notify app there's tx space if not polling */ - if (PREDICT_FALSE (is_full - && !svm_fifo_has_event (s->server_tx_fifo))) - session_dequeue_notify (s); + if (PREDICT_FALSE (want_tx_evt)) + { + svm_fifo_set_want_tx_evt (s->server_tx_fifo, 0); + session_dequeue_notify (s); + } } else if (PREDICT_FALSE (rv == SESSION_TX_NO_BUFFERS)) { @@ -882,13 +880,18 @@ skip_dequeue: break; case FIFO_EVENT_BUILTIN_RX: s = session_event_get_session (e, thread_index); - if (PREDICT_FALSE (!s)) + if (PREDICT_FALSE (!s || s->session_state >= SESSION_STATE_CLOSING)) continue; svm_fifo_unset_event (s->server_rx_fifo); app_wrk = app_worker_get (s->app_wrk_index); app = application_get (app_wrk->app_index); app->cb_fns.builtin_app_rx_callback (s); break; + case FIFO_EVENT_BUILTIN_TX: + s = session_get_from_handle_if_valid (e->session_handle); + if (PREDICT_TRUE (s != 0)) + session_tx_fifo_dequeue_internal (vm, node, e, s, &n_tx_packets); + break; case FIFO_EVENT_RPC: fp = e->rpc_args.fp; (*fp) (e->rpc_args.arg);