New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
common/libflux: Add buffer readonly setting #1548
common/libflux: Add buffer readonly setting #1548
Conversation
I can see why you struggled to come up with a good term for a read-only buffer, and this is why I gave up on adding "close" to
Maybe the drain flag could be renamed to simply "readonly"? That is literally what the "drain" flag actually is, and fits better mnemonically with EROFS error returned from a read-only buffer. |
Otherwise, seems like a nice simple approach. I also like how avoiding the term "close" let's us ignore what happens when |
Restarted a hung builder |
Add a readonly setting that allow users to read all remaining data in the buffer, but not allow any additional data to be written into the buffer. When users attempt to write data into the buffer when readonly has been set, they get an errno of EROFS.
136a055
to
c2eea95
Compare
I like the idea of calling it "readonly", simple and obvious. I went ahead and made the change, squashed changes since it's a pretty simple/obvious change (minor comment changes adjusting for English). One minor logic change is the "is_readonly" function now just returns if the buffer is readonly or not and doesn't check if the buffer is empty. The original "is_drained" function meant something somewhat different English wise. |
Restarted a builder that hit #1077 |
Great! This will be useful in #1547. Once Travis reports back I'll merge. |
hmmm, one builder hung, but did have a failure with
I doubt it's due to anything I did in this PR. Something racy? restarting the builder |
oh, we raced trying to restart the builder :-) I guess I flubbed my search, didn't see #1077. |
Ok, merged! Thanks! |
As discussed in #1546 and #1547, this adds a "drain" flag that indicates users are allowed to finish reading everything in the buffer, but can no longer write to it. It should be useful in #1547 to indicate to users that a buffer is closed and no longer available for writing.
Note that I decided to use the word "drain" for this setting. It's the best word I could come up with given the usage. Terms like "close" or "complete" didn't seem quite right. Open to suggestions of a different word.
Also, the errno I chose to return when a user attempts to write to the buffer when drain is set, is EROFS, i.e. read only file system. Not the most perfect errno, but I couldn't think of a better one.