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

Commit

Permalink
Flush pending writes on connection close. In theory this should just …
Browse files Browse the repository at this point in the history
…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)
  • Loading branch information
mbutrovich authored Jun 16, 2021
1 parent 8f38abf commit 1ea203c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/network/connection_handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ Transition ConnectionHandle::GetResult() {
}

Transition ConnectionHandle::TryCloseConnection() {
// Flush out any pending writes before closing the connection. 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
if (io_wrapper_->ShouldFlush()) TryWrite();
// Stop the protocol interpreter.
protocol_interpreter_->Teardown(io_wrapper_->GetReadBuffer(), io_wrapper_->GetWriteQueue(), traffic_cop_,
common::ManagedPointer(&context_));
Expand Down

0 comments on commit 1ea203c

Please sign in to comment.