X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvlibmemory%2Fsocket_api.c;h=24a460979f4ebd542c6f42506b301167be9d936e;hb=9db32048de0ca6be7bf855bb094c072179e163fb;hp=3df182b68b66ca76243016f7fd7b9226219fd192;hpb=79934e855fc58aefde498cd0564796cdd6ccbc59;p=vpp.git diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index 3df182b68b6..24a460979f4 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -35,7 +35,6 @@ #undef vl_typedefs /* instantiate all the print functions we know about */ -#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) #define vl_printfun #include #undef vl_printfun @@ -132,7 +131,7 @@ vl_socket_api_send (vl_api_registration_t * rp, u8 * elem) cf = vl_api_registration_file (rp); ASSERT (rp->registration_type > REGISTRATION_TYPE_SHMEM); - if (msg_id >= vec_len (am->api_trace_cfg)) + if (msg_id >= vec_len (am->msg_data)) { clib_warning ("id out of range: %d", msg_id); vl_msg_api_free ((void *) elem); @@ -221,6 +220,12 @@ static void socket_cleanup_pending_remove_registration_cb (u32 *preg_index) { vl_api_registration_t *rp = vl_socket_get_registration (*preg_index); + if (!rp) + { + /* Might already have gone */ + return; + } + clib_file_main_t *fm = &file_main; u32 pending_remove_file_index = vl_api_registration_file_index (rp); @@ -403,7 +408,7 @@ vl_socket_write_ready (clib_file_t * uf) while (remaining_bytes > 0) { bytes_to_send = remaining_bytes > 4096 ? 4096 : remaining_bytes; - n = write (uf->file_descriptor, p, bytes_to_send); + n = send (uf->file_descriptor, p, bytes_to_send, MSG_NOSIGNAL); if (n < 0) { if (errno == EAGAIN) @@ -797,12 +802,19 @@ vl_sock_api_init (vlib_main_t * vm) return 0; #define _(N, n, t) \ - vl_msg_api_set_handlers ( \ - VL_API_##N, #n, vl_api_##n##_t_handler, vl_noop_handler, \ - vl_api_##n##_t_endian, vl_api_##n##_t_print, sizeof (vl_api_##n##_t), t, \ - vl_api_##n##_t_print_json, vl_api_##n##_t_tojson, \ - vl_api_##n##_t_fromjson, vl_api_##n##_t_calc_size); \ - am->api_trace_cfg[VL_API_##N].replay_enable = 0; + vl_msg_api_config (&(vl_msg_api_msg_config_t){ \ + .id = VL_API_##N, \ + .name = #n, \ + .handler = vl_api_##n##_t_handler, \ + .endian = vl_api_##n##_t_endian, \ + .format_fn = vl_api_##n##_t_format, \ + .size = sizeof (vl_api_##n##_t), \ + .traced = t, \ + .tojson = vl_api_##n##_t_tojson, \ + .fromjson = vl_api_##n##_t_fromjson, \ + .calc_size = vl_api_##n##_t_calc_size, \ + }); \ + am->msg_data[VL_API_##N].replay_allowed = 0; foreach_vlib_api_msg; #undef _