| 173 | } |
| 174 | |
| 175 | void InternalConnection::doDetach(thread_db* tdbb) |
| 176 | { |
| 177 | fb_assert(m_attachment); |
| 178 | if (!m_attachment->getHandle()) |
| 179 | return; |
| 180 | |
| 181 | if (isCurrent()) |
| 182 | { |
| 183 | m_attachment = NULL; |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | FbLocalStatus status; |
| 188 | |
| 189 | RefPtr<JAttachment> att = m_attachment; |
| 190 | m_attachment = NULL; // release and nullify |
| 191 | |
| 192 | { // scope |
| 193 | EngineCallbackGuard guard(tdbb, *this, FB_FUNCTION); |
| 194 | att->detach(&status); |
| 195 | } |
| 196 | |
| 197 | if (!(status->getState() & IStatus::STATE_ERRORS)) |
| 198 | att.clear(); |
| 199 | |
| 200 | if (status->getErrors()[1] == isc_att_shutdown || status->getErrors()[1] == isc_shutdown) |
| 201 | { |
| 202 | status->init(); |
| 203 | } |
| 204 | |
| 205 | if (status->getState() & IStatus::STATE_ERRORS) |
| 206 | { |
| 207 | m_attachment = att; |
| 208 | raise(&status, tdbb, "JAttachment::detach"); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | fb_assert(!m_attachment); |
| 213 | } |
| 214 | |
| 215 | bool InternalConnection::cancelExecution(bool /*forced*/) |
| 216 | { |