Skip to content

Commit a0cc056

Browse files
committed
Do not flush after every CopyData message
1 parent 87b9868 commit a0cc056

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Sources/PostgresNIO/New/PostgresChannelHandler.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,13 @@ final class PostgresChannelHandler: ChannelDuplexHandler {
176176
/// `readyForMoreWriteContinuation` is resumed when the channel is able to handle more data to be written to it.
177177
func copyData(_ data: ByteBuffer, context: ChannelHandlerContext, readyForMoreWriteContinuation: CheckedContinuation<Void, Never>) {
178178
self.encoder.copyData(data: data)
179-
context.writeAndFlush(self.wrapOutboundOut(self.encoder.flushBuffer()), promise: nil)
180179
if context.channel.isWritable {
181180
readyForMoreWriteContinuation.resume()
182181
} else {
183182
self.state.waitForWritableBuffer(continuation: readyForMoreWriteContinuation)
183+
context.flush()
184184
}
185+
context.write(self.wrapOutboundOut(self.encoder.flushBuffer()), promise: nil)
185186
}
186187

187188
/// Put the state machine out of the copying mode and send a `CopyDone` message to the backend.

0 commit comments

Comments
 (0)