+static void *
+client_rx_thread_fn (void *arg)
+{
+ session_fifo_event_t _e, *e = &_e;
+ uri_tcp_test_main_t *utm = &uri_tcp_test_main;
+
+ utm->client_bytes_received = 0;
+ while (1)
+ {
+ unix_shared_memory_queue_sub (utm->our_event_queue, (u8 *) e,
+ 0 /* nowait */ );
+ switch (e->event_type)
+ {
+ case FIFO_EVENT_APP_RX:
+ client_handle_fifo_event_rx (utm, e);
+ break;
+
+ case FIFO_EVENT_DISCONNECT:
+ return 0;
+ default:
+ clib_warning ("unknown event type %d", e->event_type);
+ break;
+ }
+
+ if (PREDICT_FALSE (utm->time_to_stop == 1))
+ break;
+ }
+ pthread_exit (0);
+}
+
+
+static void
+vl_api_connect_uri_reply_t_handler (vl_api_connect_uri_reply_t * mp)
+{
+ uri_tcp_test_main_t *utm = &uri_tcp_test_main;
+ session_t *session;
+ u32 session_index;
+ svm_fifo_t *rx_fifo, *tx_fifo;
+ int rv;
+
+ if (mp->retval)
+ {
+ clib_warning ("connection failed with code: %U", format_api_error,
+ clib_net_to_host_u32 (mp->retval));
+ utm->state = STATE_FAILED;
+ return;
+ }
+
+ utm->vpp_event_queue =
+ uword_to_pointer (mp->vpp_event_queue_address,
+ unix_shared_memory_queue_t *);
+
+ /*
+ * Setup session
+ */
+
+ pool_get (utm->sessions, session);
+ session_index = session - utm->sessions;
+
+ rx_fifo = uword_to_pointer (mp->server_rx_fifo, svm_fifo_t *);
+ rx_fifo->client_session_index = session_index;
+ tx_fifo = uword_to_pointer (mp->server_tx_fifo, svm_fifo_t *);
+ tx_fifo->client_session_index = session_index;
+
+ session->server_rx_fifo = rx_fifo;
+ session->server_tx_fifo = tx_fifo;
+ session->vpp_session_handle = mp->handle;
+ session->start = clib_time_now (&utm->clib_time);
+
+ /* Save handle */
+ utm->connected_session_index = session_index;
+ utm->state = STATE_READY;
+
+ /* Add it to lookup table */
+ hash_set (utm->session_index_by_vpp_handles, mp->handle, session_index);
+
+ /* Start RX thread */
+ rv = pthread_create (&utm->client_rx_thread_handle,
+ NULL /*attr */ , client_rx_thread_fn, 0);
+ if (rv)
+ {
+ clib_warning ("pthread_create returned %d", rv);
+ rv = VNET_API_ERROR_SYSCALL_ERROR_1;
+ }
+}
+
+static void
+send_test_chunk (uri_tcp_test_main_t * utm, svm_fifo_t * tx_fifo, int mypid,
+ u32 bytes)