diff --git a/msgq/visionipc/visionipc_client.cc b/msgq/visionipc/visionipc_client.cc index 9b24da29..5245dc27 100644 --- a/msgq/visionipc/visionipc_client.cc +++ b/msgq/visionipc/visionipc_client.cc @@ -48,14 +48,22 @@ bool VisionIpcClient::connect(bool blocking){ } // Send stream type to server to request FDs int r = ipc_sendrecv_with_fds(true, socket_fd, &type, sizeof(type), nullptr, 0, nullptr); + if (r <= 0) { + close(socket_fd); + return false; + } + assert(r == sizeof(type)); // Get FDs int fds[VISIONIPC_MAX_FDS]; 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) { + close(socket_fd); + return false; + } - assert(num_buffers >= 0); assert(r == sizeof(VisionBuf) * num_buffers); // Import buffers @@ -122,11 +130,19 @@ std::set VisionIpcClient::getAvailableStreams(const std::strin // Send VISION_STREAM_MAX to server to request available streams int request = VISION_STREAM_MAX; int r = ipc_sendrecv_with_fds(true, socket_fd, &request, sizeof(request), nullptr, 0, nullptr); - assert(r == sizeof(request)); + if (r <= 0) { + close(socket_fd); + return {}; + } VisionStreamType available_streams[VISION_STREAM_MAX] = {}; r = ipc_sendrecv_with_fds(false, socket_fd, &available_streams, sizeof(available_streams), nullptr, 0, nullptr); - assert((r >= 0) && (r % sizeof(VisionStreamType) == 0)); + if (r <= 0) { + close(socket_fd); + return {}; + } + + assert((r % sizeof(VisionStreamType)) == 0); close(socket_fd); return std::set(available_streams, available_streams + r / sizeof(VisionStreamType)); } diff --git a/msgq/visionipc/visionipc_server.cc b/msgq/visionipc/visionipc_server.cc index 611d10b2..c50f3879 100644 --- a/msgq/visionipc/visionipc_server.cc +++ b/msgq/visionipc/visionipc_server.cc @@ -134,7 +134,7 @@ void VisionIpcServer::listener(){ } if (buffers.count(type) <= 0) { - std::cout << "got request for invalid buffer type: " << type << std::endl; + // std::cout << "got request for invalid buffer type: " << type << std::endl; close(fd); continue; }