namespace Cynara {
Logic::Logic(cynara_status_callback callback, void *userStatusData)
- : m_statusCallback(callback, userStatusData), m_operationPermitted(true) {
+ : m_statusCallback(callback, userStatusData), m_operationPermitted(true),
+ m_inAnswerCancelResponseCallback(false) {
m_socketClient = std::make_shared<SocketClientAsync>(
PathConfig::SocketPath::client, std::make_shared<ProtocolClient>());
m_socketClient->appendRequest(std::make_shared<CancelRequest>(it->first));
it->second.cancel();
+
+ bool onAnswerCancel = m_inAnswerCancelResponseCallback;
+ m_inAnswerCancelResponseCallback = true;
it->second.callback().onCancel(it->first);
+ m_inAnswerCancelResponseCallback = onAnswerCancel;
+
onStatusChange(m_socketClient->getSockFd(), cynara_async_status::CYNARA_STATUS_FOR_RW);
return CYNARA_API_SUCCESS;
}
+bool Logic::isFinishPermitted(void) {
+ return m_operationPermitted && !m_inAnswerCancelResponseCallback;
+}
+
bool Logic::checkCacheValid(void) {
return m_socketClient->isConnected();
}
CheckData checkData(std::move(it->second));
m_sequenceContainer.release(it->first);
m_checks.erase(it);
- if (!checkData.cancelled())
+ if (!checkData.cancelled()) {
+ bool onAnswerCancel = m_inAnswerCancelResponseCallback;
+ m_inAnswerCancelResponseCallback = true;
checkData.callback().onAnswer(
static_cast<cynara_check_id>(checkResponse->sequenceNumber()), result);
+ m_inAnswerCancelResponseCallback = onAnswerCancel;
+ }
}
void Logic::processCancelResponse(CancelResponsePtr cancelResponse) {
void *userResponseData);
virtual int process(void);
virtual int cancelRequest(cynara_check_id checkId);
+ virtual bool isFinishPermitted(void);
private:
typedef std::map<ProtocolFrameSequenceNumber, CheckData> CheckMap;
CheckMap m_checks;
SequenceContainer m_sequenceContainer;
bool m_operationPermitted;
+ bool m_inAnswerCancelResponseCallback;
bool checkCacheValid(void);
void prepareRequestsToSend(void);
* - probably cynara is unoperational (CYNARA_CALL_CAUSE_SERVICE_NOT_AVAILABLE)
* Api functions called during this callback with CYNARA_CALL_CAUSE_SERVICE_NOT_AVAILABLE
* or CYNARA_CALL_CAUSE_FINISH cause will return CYNARA_API_OPERATION_NOT_ALLOWED.
+ * cynara_async_finish() will be ignored if called from within this callback.
*
* \param[in] check_id Number identifying check request. Number is generated in
* cynara_async_create_request() and returned to user. It can be used to match
* so user should not use it in other way than waiting on it in event loop.
* In particular user should not write to, read from or close this fd.
* CYNARA_API_OPERATION_NOT_ALLOWED will be returned for every api function called in this callback.
+ * cynara_async_finish() will be ignored if called from within this callback.
*
* \param[in] old_fd Old descriptor which should be unregistered from event loop,
* Special value -1 is used when callback is called after first
*
* \par Important notes:
* No other call to cynara-async-client library should be made after call to cynara_async_finish().
+ * cynara_async_finish() called from within cynara_response_callback or cynara_status_callback will
+ * be ignored.
*
* \param[in] p_cynara cynara_async structure. If NULL, then the call has no effect.
*/