Merge #8862: Fix a few cases where messages were sent after requested disconnect

905bc68 net: fix a few cases where messages were sent rather than dropped upon disconnection (Cory Fields)
This commit is contained in:
Wladimir J. van der Laan 2016-10-04 12:13:41 +02:00
commit d93f0c6184
No known key found for this signature in database
GPG key ID: 74810B012346C9A6

View file

@ -6351,7 +6351,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
// Ping automatically sent as a latency probe & keepalive. // Ping automatically sent as a latency probe & keepalive.
pingSend = true; pingSend = true;
} }
if (pingSend) { if (pingSend && !pto->fDisconnect) {
uint64_t nonce = 0; uint64_t nonce = 0;
while (nonce == 0) { while (nonce == 0) {
GetRandBytes((unsigned char*)&nonce, sizeof(nonce)); GetRandBytes((unsigned char*)&nonce, sizeof(nonce));
@ -6432,7 +6432,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
if (pindexBestHeader == NULL) if (pindexBestHeader == NULL)
pindexBestHeader = chainActive.Tip(); pindexBestHeader = chainActive.Tip();
bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do.
if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex) { if (!state.fSyncStarted && !pto->fClient && !pto->fDisconnect && !fImporting && !fReindex) {
// Only actively request headers from a single peer, unless we're close to today. // Only actively request headers from a single peer, unless we're close to today.
if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) {
state.fSyncStarted = true; state.fSyncStarted = true;