From 8503aebba2f632cb2d4c9e2fa42f9ecec134dbfb Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Mon, 16 Dec 2024 23:07:11 -0800 Subject: [PATCH] and here in some cases --- msgq/visionipc/visionipc_client.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/msgq/visionipc/visionipc_client.cc b/msgq/visionipc/visionipc_client.cc index 88b2ff079..2330f3989 100644 --- a/msgq/visionipc/visionipc_client.cc +++ b/msgq/visionipc/visionipc_client.cc @@ -55,6 +55,13 @@ bool VisionIpcClient::connect(bool blocking){ VisionBuf bufs[VISIONIPC_MAX_FDS]; r = ipc_sendrecv_with_fds(false, socket_fd, &bufs, sizeof(bufs), fds, VISIONIPC_MAX_FDS, &num_buffers); + if (r < 0) { + // only expected error is server shutting down + assert(errno == ECONNRESET); + close(socket_fd); + return false; + } + assert(num_buffers >= 0); assert(r == sizeof(VisionBuf) * num_buffers); @@ -122,10 +129,14 @@ std::set VisionIpcClient::getAvailableStreams(const std::strin VisionStreamType available_streams[VISION_STREAM_MAX] = {}; r = ipc_sendrecv_with_fds(false, socket_fd, &available_streams, sizeof(available_streams), nullptr, 0, nullptr); + if (r < 0) { + // only expected error is server shutting down + assert(errno == ECONNRESET); close(socket_fd); return {}; } + assert(r % sizeof(VisionStreamType) == 0); close(socket_fd); return std::set(available_streams, available_streams + r / sizeof(VisionStreamType));