function pointer may be null

This commit is contained in:
Jeff Tao 2020-07-28 07:30:13 +00:00
parent c9bcfe5fa6
commit be58861a59
2 changed files with 5 additions and 3 deletions

View File

@ -537,7 +537,8 @@ static void syncResetFlowCtrl(SSyncNode *pNode) {
pNode->peerInfo[i]->numOfRetrieves = 0;
}
(*pNode->notifyFlowCtrl)(pNode->ahandle, 0);
if (pNode->notifyFlowCtrl)
(*pNode->notifyFlowCtrl)(pNode->ahandle, 0);
}
static void syncChooseMaster(SSyncNode *pNode) {

View File

@ -477,11 +477,12 @@ void *syncRetrieveData(void *param)
if (pPeer->fileChanged) {
// if file is changed 3 times continuously, start flow control
pPeer->numOfRetrieves++;
if (pPeer->numOfRetrieves >= 3)
if (pPeer->numOfRetrieves >= 3 && pNode->notifyFlowCtrl)
(*pNode->notifyFlowCtrl)(pNode->ahandle, pPeer->numOfRetrieves - 2);
} else {
pPeer->numOfRetrieves = 0;
(*pNode->notifyFlowCtrl)(pNode->ahandle, 0);
if (pNode->notifyFlowCtrl)
(*pNode->notifyFlowCtrl)(pNode->ahandle, 0);
}
pPeer->fileChanged = 0;