diff options
author | Florin Coras <fcoras@cisco.com> | 2019-01-02 19:31:22 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2019-01-05 21:53:16 +0000 |
commit | 30e79c2e388a98160a3660f4f03103890c9b1b7c (patch) | |
tree | 0b108f43d95e28304924cc6e1d43900b3046c8de /src/vnet/session/application.c | |
parent | 3c1cf2c1716f436e5da4a106dd2b9a3df5d3a4a3 (diff) |
vcl/session: add api for changing session app worker
In case of multi process apps, after forking, the parent may decide to
close part or all of the sessions it shares with the child. Because the
sessions have fifos allocated in the parent's segment manager, they must
be moved to the child's segment manager.
Change-Id: I85b4c8c8545005724023ee14043647719cef61dd
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/application.c')
-rw-r--r-- | src/vnet/session/application.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c index 19c8fa2f2e0..85b5f939427 100644 --- a/src/vnet/session/application.c +++ b/src/vnet/session/application.c @@ -724,6 +724,48 @@ app_worker_stop_listen (app_worker_t * app_wrk, session_handle_t handle) return 0; } +int +app_worker_own_session (app_worker_t * app_wrk, stream_session_t * s) +{ + segment_manager_t *sm; + svm_fifo_t *rxf, *txf; + + s->app_wrk_index = app_wrk->wrk_index; + + rxf = s->server_rx_fifo; + txf = s->server_tx_fifo; + + if (!rxf || !txf) + return 0; + + s->server_rx_fifo = 0; + s->server_tx_fifo = 0; + + sm = app_worker_get_or_alloc_connect_segment_manager (app_wrk); + if (session_alloc_fifos (sm, s)) + return -1; + + if (!svm_fifo_is_empty (rxf)) + { + clib_memcpy_fast (s->server_rx_fifo->data, rxf->data, rxf->nitems); + s->server_rx_fifo->head = rxf->head; + s->server_rx_fifo->tail = rxf->tail; + s->server_rx_fifo->cursize = rxf->cursize; + } + + if (!svm_fifo_is_empty (txf)) + { + clib_memcpy_fast (s->server_tx_fifo->data, txf->data, txf->nitems); + s->server_tx_fifo->head = txf->head; + s->server_tx_fifo->tail = txf->tail; + s->server_tx_fifo->cursize = txf->cursize; + } + + segment_manager_dealloc_fifos (rxf->segment_index, rxf, txf); + + return 0; +} + /** * Start listening local transport endpoint for requested transport. * @@ -890,6 +932,14 @@ app_worker_get_connect_segment_manager (app_worker_t * app) } segment_manager_t * +app_worker_get_or_alloc_connect_segment_manager (app_worker_t * app_wrk) +{ + if (app_wrk->connects_seg_manager == (u32) ~ 0) + app_worker_alloc_connects_segment_manager (app_wrk); + return segment_manager_get (app_wrk->connects_seg_manager); +} + +segment_manager_t * app_worker_get_listen_segment_manager (app_worker_t * app, stream_session_t * listener) { |