Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

check for mapped reader #74

Merged
merged 3 commits into from
Aug 7, 2023

Conversation

nclack
Copy link
Member

@nclack nclack commented Aug 4, 2023

Fixes an unchecked failure in acquire_map_read() caused when a caller fails to call acquire_unmap_read() at the right time.

For example:

acquire_map_read(runtime,0,&beg,&end);
// When end>beg
acquire_map_read(runtime,0,beg,end); // Should return AcquireStatus_Error

whereas

acquire_map_read(runtime,0,&beg,&end);
// When end>beg
acquire_unmap_read(runtime,0,&beg,&end);
acquire_map_read(runtime,0,beg,end); // Should return AcquireStatus_Ok

acquire-project/acquire-driver-common#34 depends on this

src/acquire.c Outdated
@@ -98,6 +98,8 @@ acquire_map_read(const struct AcquireRuntime* self_,
self = containerof(self_, struct runtime, handle);
struct vfslice_mut slice = make_vfslice_mut(channel_read_map(
&self->video[istream].sink.in, &self->video[istream].monitor.reader));
EXPECT(self->video[istream].monitor.reader.status == Channel_Ok,
"Expected an unmapped reader. See acquire_unmap_read().");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming unmapped reader (i.e., Channel_Expected_Unmapped_Reader) is the most common failure mode? The other option for status from channel_read_map is Channel_Error in the case of overflow. The error message here is misleading in that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, Channel_Error indicates something is wrong with the code in channel.c itself; it never happens due to a user error. That said, I'll improve the error checking here.

Copy link
Contributor

@andy-sweet andy-sweet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@nclack nclack merged commit a32633e into acquire-project:main Aug 7, 2023
4 checks passed
@nclack nclack deleted the add-check-for-mapped-reader branch August 7, 2023 16:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants