Conversation

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.

This comment has been minimized.

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 flux_buffer_t interface (the idea of it just doesn't fit). However, drain might not be the best choice for the public API because this term is already used in other similar software, e.g.

This comment has been minimized.

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.

This comment has been minimized.

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.

This comment has been minimized.

Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.