Browse Source

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.
0.14
Cory Fields 8 years ago
parent
commit
905bc68d05
  1. 4
      src/main.cpp

4
src/main.cpp

@ -6351,7 +6351,7 @@ bool SendMessages(CNode* pto, CConnman& connman) @@ -6351,7 +6351,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
// 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));
@ -6432,7 +6432,7 @@ bool SendMessages(CNode* pto, CConnman& connman) @@ -6432,7 +6432,7 @@ bool SendMessages(CNode* pto, CConnman& connman)
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;

Loading…
Cancel
Save