X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Ftests%2Fvnet%2Fsession%2Ftcp_echo.c;h=f37a7272b23a638766bd0be443047cb3bdc12bb2;hb=f7f4e399e04774a6ca00b67006610f5b8f7a37c6;hp=6c99294099b8c90237e403e45c0e8637ad86e98b;hpb=52207f1b7b60cb0784d5241f0a4d40eef531c67e;p=vpp.git diff --git a/src/tests/vnet/session/tcp_echo.c b/src/tests/vnet/session/tcp_echo.c index 6c99294099b..f37a7272b23 100644 --- a/src/tests/vnet/session/tcp_echo.c +++ b/src/tests/vnet/session/tcp_echo.c @@ -353,7 +353,7 @@ memfd_segment_attach (void) clib_error_t *error; int rv; - if ((error = vl_socket_client_recv_fd_msg (&ssvm->fd, 5))) + if ((error = vl_socket_client_recv_fd_msg (&ssvm->fd, 1, 5))) { clib_error_report (error); return -1; @@ -379,7 +379,7 @@ fifo_segment_attach (char *name, u32 size, ssvm_segment_type_t type) if (type == SSVM_SEGMENT_MEMFD) { - if ((error = vl_socket_client_recv_fd_msg (&a->memfd_fd, 5))) + if ((error = vl_socket_client_recv_fd_msg (&a->memfd_fd, 1, 5))) { clib_error_report (error); return -1; @@ -621,7 +621,7 @@ send_test_chunk (echo_main_t * em, session_t * s) u64 test_buf_len, bytes_this_chunk, test_buf_offset; svm_fifo_t *tx_fifo = s->server_tx_fifo; u8 *test_data = em->connect_test_data; - u32 enq_space, min_chunk = 16 << 10; + u32 enq_space = 16 << 10; int written; test_buf_len = vec_len (test_data); @@ -629,8 +629,6 @@ send_test_chunk (echo_main_t * em, session_t * s) bytes_this_chunk = clib_min (test_buf_len - test_buf_offset, s->bytes_to_send); enq_space = svm_fifo_max_enqueue (tx_fifo); - if (enq_space < clib_min (bytes_this_chunk, min_chunk)) - return; bytes_this_chunk = clib_min (bytes_this_chunk, enq_space); written = svm_fifo_enqueue_nowait (tx_fifo, bytes_this_chunk, @@ -881,20 +879,16 @@ session_disconnected_handler (session_disconnected_msg_t * mp) int rv = 0; p = hash_get (em->session_index_by_vpp_handles, mp->handle); - - if (p) - { - clib_warning ("disconnected"); - session = pool_elt_at_index (em->sessions, p[0]); - hash_unset (em->session_index_by_vpp_handles, mp->handle); - pool_put (em->sessions, session); - } - else + if (!p) { clib_warning ("couldn't find session key %llx", mp->handle); - rv = -11; + return; } + session = pool_elt_at_index (em->sessions, p[0]); + hash_unset (em->session_index_by_vpp_handles, mp->handle); + pool_put (em->sessions, session); + app_alloc_ctrl_evt_to_vpp (session->vpp_evt_q, app_evt, SESSION_CTRL_EVT_DISCONNECTED_REPLY); rmp = (session_disconnected_reply_msg_t *) app_evt->evt->data; @@ -903,8 +897,7 @@ session_disconnected_handler (session_disconnected_msg_t * mp) rmp->context = mp->context; app_send_ctrl_evt_to_vpp (session->vpp_evt_q, app_evt); - if (session) - session_print_stats (em, session); + session_print_stats (em, session); } static void @@ -1409,21 +1402,14 @@ main (int argc, char **argv) echo_main_t *em = &echo_main; unformat_input_t _argv, *a = &_argv; u8 *chroot_prefix; - u8 *heap, *uri = 0; + u8 *uri = 0; u8 *bind_uri = (u8 *) "tcp://0.0.0.0/1234"; u8 *connect_uri = (u8 *) "tcp://6.0.1.1/1234"; u64 bytes_to_send = 64 << 10, mbytes; char *app_name; u32 tmp; - mheap_t *h; - - clib_mem_init (0, 256 << 20); - - heap = clib_mem_get_per_cpu_heap (); - h = mheap_header (heap); - /* make the main heap thread-safe */ - h->flags |= MHEAP_FLAG_THREAD_SAFE; + clib_mem_init_thread_safe (0, 256 << 20); memset (em, 0, sizeof (*em)); em->session_index_by_vpp_handles = hash_create (0, sizeof (uword));