diff options
author | Ole Troan <ot@cisco.com> | 2022-12-06 17:07:39 +0100 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2022-12-07 10:33:07 +0000 |
commit | d7413835e1478b0c1356bae7d45e00061d7eb8d4 (patch) | |
tree | 09f7bc0934f5ed5c64c6b0772798e3d8265a2de3 /src/vlibmemory/socket_api.c | |
parent | f22824bbefdf82168717537090a5471166e20f0d (diff) |
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 <ot@cisco.com>
Change-Id: Iac7705ec09ccd67cc249cc9a9525a7cb379e2f6f
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/vlibmemory/socket_api.c')
-rw-r--r-- | src/vlibmemory/socket_api.c | 8 |
1 files changed, 7 insertions, 1 deletions
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) |