aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session-apps/echo_client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session-apps/echo_client.c')
-rw-r--r--src/vnet/session-apps/echo_client.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/vnet/session-apps/echo_client.c b/src/vnet/session-apps/echo_client.c
index b47dcf21a4b..0258c16520a 100644
--- a/src/vnet/session-apps/echo_client.c
+++ b/src/vnet/session-apps/echo_client.c
@@ -208,7 +208,7 @@ echo_client_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
connections_this_batch =
ecm->connections_this_batch_by_thread[my_thread_index];
- if ((ecm->run_test == 0) ||
+ if ((ecm->run_test != ECHO_CLIENTS_RUNNING) ||
((vec_len (connection_indices) == 0)
&& vec_len (connections_this_batch) == 0))
return 0;
@@ -352,6 +352,16 @@ echo_clients_init (vlib_main_t * vm)
return 0;
}
+static void
+echo_clients_session_disconnect (stream_session_t * s)
+{
+ echo_client_main_t *ecm = &echo_client_main;
+ vnet_disconnect_args_t _a, *a = &_a;
+ a->handle = session_handle (s);
+ a->app_index = ecm->app_index;
+ vnet_disconnect_session (a);
+}
+
static int
echo_clients_session_connected_callback (u32 app_index, u32 api_context,
stream_session_t * s, u8 is_fail)
@@ -361,6 +371,9 @@ echo_clients_session_connected_callback (u32 app_index, u32 api_context,
u32 session_index;
u8 thread_index;
+ if (PREDICT_FALSE (ecm->run_test != ECHO_CLIENTS_STARTING))
+ return -1;
+
if (is_fail)
{
clib_warning ("connection %d failed!", api_context);
@@ -407,7 +420,7 @@ echo_clients_session_connected_callback (u32 app_index, u32 api_context,
__sync_fetch_and_add (&ecm->ready_connections, 1);
if (ecm->ready_connections == ecm->expected_connections)
{
- ecm->run_test = 1;
+ ecm->run_test = ECHO_CLIENTS_RUNNING;
/* Signal the CLI process that the action is starting... */
signal_evt_to_cli (1);
}
@@ -447,6 +460,12 @@ echo_clients_rx_callback (stream_session_t * s)
echo_client_main_t *ecm = &echo_client_main;
eclient_session_t *sp;
+ if (PREDICT_FALSE (ecm->run_test != ECHO_CLIENTS_RUNNING))
+ {
+ echo_clients_session_disconnect (s);
+ return -1;
+ }
+
sp = pool_elt_at_index (ecm->sessions,
s->server_rx_fifo->client_session_index);
receive_data_chunk (ecm, sp);
@@ -624,6 +643,7 @@ echo_clients_command_fn (vlib_main_t * vm,
ecm->vlib_main = vm;
ecm->tls_engine = TLS_ENGINE_OPENSSL;
ecm->no_copy = 0;
+ ecm->run_test = ECHO_CLIENTS_STARTING;
if (thread_main->n_vlib_mains > 1)
clib_spinlock_init (&ecm->sessions_lock);
@@ -825,7 +845,7 @@ echo_clients_command_fn (vlib_main_t * vm,
error = clib_error_return (0, "failed: test bytes");
cleanup:
- ecm->run_test = 0;
+ ecm->run_test = ECHO_CLIENTS_EXITING;
vlib_process_wait_for_event_or_clock (vm, 10e-3);
for (i = 0; i < vec_len (ecm->connection_index_by_thread); i++)
{