Skip to content

Commit 090ed9b

Browse files
committed
Added handleFatalError in handleClosed
1 parent 59cd436 commit 090ed9b

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

orm_lib/src/postgresql_impl/PgConnection.cc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,15 @@ void PgConnection::handleClosed()
133133
if (status_ == ConnectStatus::Bad)
134134
return;
135135
status_ = ConnectStatus::Bad;
136+
137+
if (isWorking_)
138+
{
139+
// Connection was closed unexpectedly during isWorking_ while were true.
140+
isWorking_ = false;
141+
handleFatalError();
142+
callback_ = nullptr;
143+
}
144+
136145
channel_.disableAll();
137146
channel_.remove();
138147
assert(closeCallback_);
@@ -406,10 +415,13 @@ void PgConnection::doAfterPreparing()
406415

407416
void PgConnection::handleFatalError()
408417
{
409-
auto exceptPtr =
410-
std::make_exception_ptr(Failure(PQerrorMessage(connectionPtr_.get())));
411418
if (exceptionCallback_)
419+
{
420+
auto exceptPtr = std::make_exception_ptr(
421+
Failure(PQerrorMessage(connectionPtr_.get())));
412422
exceptionCallback_(exceptPtr);
423+
}
424+
413425
exceptionCallback_ = nullptr;
414426
}
415427

0 commit comments

Comments
 (0)