Skip to content
This repository was archived by the owner on Feb 20, 2023. It is now read-only.

Commit 1ea203c

Browse files
authored
Flush pending writes on connection close. In theory this should just be error messages and not partial query data, but I don't completely understand the network state machine. This is mostly to make sure we flush error messages on connection startup. See PostgresProtocolInterpreter::ProcessStartup's error states. (#1617)
1 parent 8f38abf commit 1ea203c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/network/connection_handle.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ Transition ConnectionHandle::GetResult() {
193193
}
194194

195195
Transition ConnectionHandle::TryCloseConnection() {
196+
// Flush out any pending writes before closing the connection. In theory this should just be error messages and not
197+
// partial query data, but I don't completely understand the network state machine. This is mostly to make sure we
198+
// flush error messages on connection startup. @see PostgresProtocolInterpreter::ProcessStartup's error states
199+
if (io_wrapper_->ShouldFlush()) TryWrite();
196200
// Stop the protocol interpreter.
197201
protocol_interpreter_->Teardown(io_wrapper_->GetReadBuffer(), io_wrapper_->GetWriteQueue(), traffic_cop_,
198202
common::ManagedPointer(&context_));

0 commit comments

Comments
 (0)