diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2016-09-12 21:32:53 -0400 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-10-13 20:09:31 +0200 |
commit | 7ae624296000e714034d86891ffcd4a565f278fa (patch) | |
tree | 8e92ecfb38b794cf47f483d0376670d4c134fe8d /src | |
parent | 3e80ab7f2a338d1bb3d9321c13a18f1324130617 (diff) | |
download | bitcoin-7ae624296000e714034d86891ffcd4a565f278fa.tar.xz |
net: fix a few cases where messages were sent rather than dropped upon disconnection
75ead758 turned these into crashes in the event of a handshake failure, most
notably when a peer does not offer the expected services.
There are likely other cases that these assertions will find as well.
Github-Pull: #8862
Rebased-From: 905bc68d05595f41cca36b3df83accd10c00cc48
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index c9869d04f9..c8e290ae51 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6342,7 +6342,7 @@ bool SendMessages(CNode* pto) // Ping automatically sent as a latency probe & keepalive. pingSend = true; } - if (pingSend) { + if (pingSend && !pto->fDisconnect) { uint64_t nonce = 0; while (nonce == 0) { GetRandBytes((unsigned char*)&nonce, sizeof(nonce)); @@ -6423,7 +6423,7 @@ bool SendMessages(CNode* pto) if (pindexBestHeader == NULL) 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. - 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. if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { state.fSyncStarted = true; |