!1249 fix: add retry for receive reply message

Merge pull request !1249 from Mark/20240801
This commit is contained in:
openharmony_ci 2024-08-01 14:38:26 +00:00 committed by Gitee
commit 933af94ee5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 13 additions and 6 deletions

View File

@ -130,6 +130,8 @@ private:
private:
std::mutex objectMutex_;
static constexpr int32_t REPLY_RETRY_COUNT = 5;
static constexpr int32_t REPLY_RETRY_WAIT_MS = 10;
};
} // namespace OHOS
#endif // OHOS_IPC_DBINDER_BASE_INVOKER_DEFINE_H

View File

@ -127,12 +127,17 @@ template <class T> void DBinderBaseInvoker<T>::ProcessReply(dbinder_transaction_
}
std::shared_ptr<ThreadMessageInfo> messageInfo = current->QueryThreadBySeqNumber(tr->seqNumber);
if (messageInfo == nullptr) {
ZLOGE(LOG_LABEL, "no thread waiting reply message of this seqNumber:%{public}llu listenFd:%{public}d",
tr->seqNumber, listenFd);
DfxReportFailListenEvent(DbinderErrorCode::RPC_DRIVER, listenFd, RADAR_SEQ_MESSAGE_NULL, __FUNCTION__);
/* messageInfo is null, no thread need to wakeup */
return;
int32_t retryCount = 0;
while (messageInfo == nullptr) {
ZLOGW(LOG_LABEL, "query thread for reply failed, seqNum:%{public}llu, listenFd:%{public}d, retry:%{public}d",
tr->seqNumber, listenFd, retryCount++);
if (retryCount == REPLY_RETRY_COUNT) {
ZLOGE(LOG_LABEL, "query thread for reply failed, no thread waiting reply message");
DfxReportFailListenEvent(DbinderErrorCode::RPC_DRIVER, listenFd, RADAR_SEQ_MESSAGE_NULL, __FUNCTION__);
return; // messageInfo is null, no thread need to wakeup
}
std::this_thread::sleep_for(std::chrono::milliseconds(REPLY_RETRY_WAIT_MS));
messageInfo = current->QueryThreadBySeqNumber(tr->seqNumber);
}
/* tr->sizeOfSelf > sizeof(dbinder_transaction_data) is checked in CheckTransactionData */