Skip to content

Commit

Permalink
Fix flush methods to always flush underlying IO (#9320)
Browse files Browse the repository at this point in the history
* Fix flush methods to always flush underlying IO

* fixup! Fix flush methods to always flush underlying IO
  • Loading branch information
straight-shoota authored Jun 1, 2020
1 parent 766c927 commit bffe450
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
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

0 comments on commit bffe450

Please sign in to comment.