Skip to content

Commit

Permalink
It should fix bug CORE-5685 : Sometime it is impossible to cancel\kil…
Browse files Browse the repository at this point in the history
…l connection executing external query
  • Loading branch information
hvlad committed Dec 20, 2017
1 parent 5a633f5 commit 257c5c4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/jrd/extds/ExtDS.cpp
Expand Up @@ -277,7 +277,7 @@ void Provider::cancelConnections(thread_db* tdbb)
Connection** end = m_connections.end();

for (; ptr < end; ptr++) {
(*ptr)->cancelExecution(tdbb);
(*ptr)->cancelExecution(tdbb, true);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/jrd/extds/ExtDS.h
Expand Up @@ -162,7 +162,7 @@ class Connection : public Firebird::PermanentStorage
const Firebird::string& role) = 0;
virtual void detach(Jrd::thread_db* tdbb);

virtual bool cancelExecution(Jrd::thread_db* tdbb) = 0;
virtual bool cancelExecution(Jrd::thread_db* tdbb, bool forced) = 0;

int getSqlDialect() const { return m_sqlDialect; }

Expand Down
2 changes: 1 addition & 1 deletion src/jrd/extds/InternalDS.cpp
Expand Up @@ -188,7 +188,7 @@ void InternalConnection::doDetach(thread_db* tdbb)
fb_assert(!m_attachment);
}

bool InternalConnection::cancelExecution(thread_db* tdbb)
bool InternalConnection::cancelExecution(thread_db* tdbb, bool /*forced*/)
{
if (m_isCurrent)
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/extds/InternalDS.h
Expand Up @@ -67,7 +67,7 @@ class InternalConnection : public Connection
const Firebird::string& user, const Firebird::string& pwd,
const Firebird::string& role);

virtual bool cancelExecution(Jrd::thread_db* tdbb);
virtual bool cancelExecution(Jrd::thread_db* tdbb, bool forced);

virtual bool isAvailable(Jrd::thread_db* tdbb, TraScope traScope) const;

Expand Down
7 changes: 4 additions & 3 deletions src/jrd/extds/IscDS.cpp
Expand Up @@ -193,14 +193,15 @@ void IscConnection::doDetach(thread_db* tdbb)
raise(status, tdbb, "detach");
}

bool IscConnection::cancelExecution(thread_db* /*tdbb*/)
bool IscConnection::cancelExecution(thread_db* /*tdbb*/, bool forced)
{
ISC_STATUS_ARRAY status = {0, 0, 0};
if (m_handle)
{
m_iscProvider.fb_cancel_operation(status, &m_handle, fb_cancel_raise);
m_iscProvider.fb_cancel_operation(status, &m_handle,
forced ? fb_cancel_abort : fb_cancel_raise);

if (m_handle && status[1] == isc_wish_list)
if (!forced && m_handle && status[1] != FB_SUCCESS && status[1] != isc_bad_db_handle)
{
fb_utils::init_status(status);
m_iscProvider.fb_cancel_operation(status, &m_handle, fb_cancel_abort);
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/extds/IscDS.h
Expand Up @@ -514,7 +514,7 @@ class IscConnection : public Connection
const Firebird::string& user, const Firebird::string& pwd,
const Firebird::string& role);

virtual bool cancelExecution(Jrd::thread_db* tdbb);
virtual bool cancelExecution(Jrd::thread_db* tdbb, bool forced);

virtual bool isAvailable(Jrd::thread_db* tdbb, TraScope traScope) const;

Expand Down
9 changes: 7 additions & 2 deletions src/jrd/jrd.cpp
Expand Up @@ -1728,6 +1728,11 @@ ISC_STATUS FB_CANCEL_OPERATION(ISC_STATUS* user_status, Attachment** handle, USH
attachment->signalCancel(tdbb);
break;

case fb_cancel_abort:
if (!(attachment->att_flags & ATT_shutdown))
attachment->signalShutdown(tdbb);
break;

default:
fb_assert(false);
}
Expand Down Expand Up @@ -5727,7 +5732,7 @@ void Attachment::signalCancel(thread_db* tdbb)
att_flags |= ATT_cancel_raise;

if (att_ext_connection)
att_ext_connection->cancelExecution(tdbb);
att_ext_connection->cancelExecution(tdbb, false);

LCK_cancel_wait(this);
}
Expand All @@ -5737,7 +5742,7 @@ void Attachment::signalShutdown(thread_db* tdbb)
att_flags |= ATT_shutdown;

if (att_ext_connection)
att_ext_connection->cancelExecution(tdbb);
att_ext_connection->cancelExecution(tdbb, true);

LCK_cancel_wait(this);
}
Expand Down

0 comments on commit 257c5c4

Please sign in to comment.