File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ class DbConnection : public trantor::NonCopyable
118118
119119 virtual ~DbConnection ()
120120 {
121- LOG_TRACE << " Destruct DbConn" << this ;
121+ LOG_TRACE << " Destruct DbConn " << this ;
122122 }
123123
124124 ConnectStatus status () const
Original file line number Diff line number Diff 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 while isWorking_ was 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
407416void 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
You can’t perform that action at this time.
0 commit comments