[pull] master from ruby:master - #1423
Merged
Merged
Conversation
When a stream is in sync mode (`sync == true`), writes go straight to the
operating system and Ruby's write buffer is not authoritative. Any bytes
left in the write buffer are therefore the result of writes made while
sync was disabled.
Previously `#close` always flushed the write buffer, replaying those
bytes. After an interrupted write - for example a buffered write
cancelled by a fiber scheduler - the number of bytes actually written is
indeterminate, so replaying the buffer on close can duplicate or corrupt
data on a stream.
Gate the finalize flush on sync mode, so that:
io.sync = true
io.close # discards the pending write buffer instead of replaying it
provides a supported way to abandon buffered output. Call `flush` before
enabling sync if the buffered data should still be sent.
Sync-mode streams (including transcoding streams, which write converted
bytes directly) do not rely on the finalize flush, so normal sync usage
is unaffected.
Assisted-By: devx/2c064143-8655-4631-a7cd-6395bb241bdc
GCC was emitting a warning, because it couldn't understand that
`search->needles_count` was assumed not to be 0:
```
string.c:9673:36: warning: ‘matches’ may be used uninitialized [-Wmaybe-uninitialized]
9673 | const int bitmap = _mm_movemask_epi8(matches[0]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
string.c: In function ‘tr_trans_pairs’:
string.c:9664:25: note: ‘matches’ declared here
9664 | __m128i matches[TR_TRANS_PAIRS_SIMD_MAX_NEEDLES];
|
```
Instead of adding some useless initialization (41c9fdd)
we can try copying the loop upper bound into a `const` so that the compiler
can understand it's never 0;
Making `RBIMPL_ASSERT_OR_ASSUME(needles_count > 0);` redundant.
Ruby and CPU heap doesn't make any sense when using the NoGC plan. ruby/mmtk@85f97bb0d9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )