Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion msgq/visionipc/visionipc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ int ipc_sendrecv_with_fds(bool send, int fd, void *buf, size_t buf_size, int* fd
return sendmsg(fd, &msg, 0);
} else {
int r = recvmsg(fd, &msg, 0);
if (r < 0) return r;
if (r <= 0) {
// r == 0: peer closed connection (EOF)
// r < 0: error occurred (check errno)
return r;
}

int recv_fds = 0;
if (msg.msg_controllen > 0) {
Expand Down
20 changes: 15 additions & 5 deletions msgq/visionipc/visionipc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ bool VisionIpcClient::connect(bool blocking){
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) {
if (r <= 0) {
// only expected error is server shutting down
assert(errno == ECONNRESET);
if (r == 0) {
LOGE("server closed connection");
} else {
assert(errno == ECONNRESET);
LOGE("recv failed: %d", errno);
}
close(socket_fd);
return false;
}
Expand Down Expand Up @@ -135,9 +140,14 @@ std::set<VisionStreamType> 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);
if (r <= 0) {
if (r == 0) {
LOGE("server closed connection");
} else {
// only expected error is server shutting down
assert(errno == ECONNRESET);
LOGE("recv failed: %d", errno);
}
close(socket_fd);
return {};
}
Expand Down
Loading