From d7413835e1478b0c1356bae7d45e00061d7eb8d4 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Tue, 6 Dec 2022 17:07:39 +0100 Subject: api: avoid sigpipe for unruly api client if the api client didn't wait for the last message, we'd get a SIGPIPE from Unix and VPP would crash. Type: fix Signed-off-by: Ole Troan Change-Id: Iac7705ec09ccd67cc249cc9a9525a7cb379e2f6f Signed-off-by: Ole Troan --- src/vlibmemory/socket_api.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/vlibmemory/socket_api.c b/src/vlibmemory/socket_api.c index 6559f733393..24a460979f4 100644 --- a/src/vlibmemory/socket_api.c +++ b/src/vlibmemory/socket_api.c @@ -220,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); @@ -402,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) -- cgit 1.2.3-korg