Skip to content
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
2 changes: 1 addition & 1 deletion orm_lib/src/DbConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class DbConnection : public trantor::NonCopyable

virtual ~DbConnection()
{
LOG_TRACE << "Destruct DbConn" << this;
LOG_TRACE << "Destruct DbConn " << this;
}

ConnectStatus status() const
Expand Down
16 changes: 14 additions & 2 deletions orm_lib/src/postgresql_impl/PgConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ void PgConnection::handleClosed()
if (status_ == ConnectStatus::Bad)
return;
status_ = ConnectStatus::Bad;

if (isWorking_)
{
// Connection was closed unexpectedly while isWorking_ was true.
isWorking_ = false;
handleFatalError();
callback_ = nullptr;
}

channel_.disableAll();
channel_.remove();
assert(closeCallback_);
Expand Down Expand Up @@ -406,10 +415,13 @@ void PgConnection::doAfterPreparing()

void PgConnection::handleFatalError()
{
auto exceptPtr =
std::make_exception_ptr(Failure(PQerrorMessage(connectionPtr_.get())));
if (exceptionCallback_)
{
auto exceptPtr = std::make_exception_ptr(
Failure(PQerrorMessage(connectionPtr_.get())));
exceptionCallback_(exceptPtr);
}

exceptionCallback_ = nullptr;
}

Expand Down
Loading