Skip to content

Commit

Permalink
and here in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Dec 17, 2024
1 parent 9f2822c commit 8503aeb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions msgq/visionipc/visionipc_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -122,10 +129,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);
close(socket_fd);
return {};
}

assert(r % sizeof(VisionStreamType) == 0);
close(socket_fd);
return std::set<VisionStreamType>(available_streams, available_streams + r / sizeof(VisionStreamType));
Expand Down

0 comments on commit 8503aeb

Please sign in to comment.