in src/dxapi/native/tickdb/http/tickcursor_http.cpp [1368:1440]
void TickCursorImpl::close(bool shouldSendCloseRequest, bool noThrow)
{
yield_lock section(closeLock_);
if (isOpen_)
{
try {
DBGLOG_VERBOSE(LOGHDR ".close(): attempting to close", ID);
// First, we set "stream end flag", break the connection
if (isInNext_) {
DBGLOG_VERBOSE(LOGHDR ".close(): client is inside Next()", ID);
}
interruptedTimeout_ = false;
isInterrupted_ = true;
setState(CursorState::END);
if (shouldSendCloseRequest) {
sendCloseRequest();
}
forn(i, CURSOR_STOPPING_WAIT_MAX_MS / CURSOR_STOPPING_WAIT_MIN_MS) {
if (!isOpen_) {
goto closed;
}
this_thread::sleep_for(chrono::milliseconds(CURSOR_STOPPING_WAIT_MIN_MS));
if (!isInNext_) {
break;
}
}
interruptedTimeout_ = true;
this_thread::sleep_for(chrono::milliseconds(CURSOR_STOPPING_WAIT_MIN_MS));
// Still open?
readRemainderAndClose(false);
closed:
DBGLOG_VERBOSE(LOGHDR ".close(): closed", ID);
}
catch (const IOStreamDisconnectException&) {
DBGLOG(LOGHDR ".close(): Server disconnected", ID);
doClose();
}
catch (const IOStreamException& e) {
DBGLOG(LOGHDR ".close(): I/O exception was unexpected: %s%s", ID, e.what(), noThrow ? " (not rethrown)" : "");
doClose();
if (!noThrow)
throw;
}
catch (const std::exception &e) {
DBGLOG(LOGHDR ".close(): std::exception: %s%s", ID, e.what(), noThrow ? " (not rethrown)" : "");
doClose();
if (!noThrow)
throw;
}
catch (...) {
DBGLOG(LOGHDR ".close(): ERROR: Unknowns exception!%s", ID, noThrow ? " (not rethrown)" : "");
doClose();
if (!noThrow)
throw;
}
}
else {
DBGLOG_VERBOSE(LOGHDR ".close(): already closed", ID);
}
}