Skip to content
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

Fix flush methods to always flush underlying IO #9320

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compress/deflate/writer.cr
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class Compress::Deflate::Writer < IO
return if @closed

consume_output LibZ::Flush::SYNC_FLUSH
@output.flush
end

# Closes this writer. Must be invoked after all data has been written.
Expand Down
2 changes: 2 additions & 0 deletions src/pretty_print.cr
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ class PrettyPrint
end
@buffer.clear
@buffer_width = 0

@output.flush
end

private class Text
Expand Down
5 changes: 3 additions & 2 deletions src/xml/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct XML::Builder
@box : Void*

# Creates a builder that writes to the given *io*.
def initialize(io : IO)
def initialize(@io : IO)
@box = Box.box(io)
buffer = LibXML.xmlOutputBufferCreateIO(
->(ctx, buffer, len) {
Expand Down Expand Up @@ -249,6 +249,8 @@ struct XML::Builder
# this writer's `IO`.
def flush
call Flush

@io.flush
end

# Sets the indent string.
Expand Down Expand Up @@ -376,7 +378,6 @@ module XML
# when StartDocument is omitted.
xml.end_document
xml.flush
io.flush
v
end
end
2 changes: 2 additions & 0 deletions src/yaml/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ class YAML::Builder
# Flushes any pending data to the underlying `IO`.
def flush
LibYAML.yaml_emitter_flush(@emitter)

@io.flush
end

def finalize
Expand Down