net: deserialize the entire version message locally

This avoids having some vars set if the version negotiation fails.

Also copy it all into CNode at the same site. nVersion and
fSuccessfullyConnected are set last, as they are the gates for the other vars.
Make them atomic for that reason.
This commit is contained in:
Cory Fields
2017-01-18 18:15:00 -05:00
parent 80ff0344ae
commit 2046617b5e
2 changed files with 36 additions and 29 deletions

View File

@@ -627,7 +627,7 @@ public:
const CAddress addr;
std::string addrName;
CService addrLocal;
int nVersion;
std::atomic<int> nVersion;
// strSubVer is whatever byte array we read from the wire. However, this field is intended
// to be printed out, displayed to humans in various forms and so on. So we sanitize it and
// store the sanitized version in cleanSubVer. The original should be used when dealing with
@@ -639,7 +639,7 @@ public:
bool fAddnode;
bool fClient;
const bool fInbound;
bool fSuccessfullyConnected;
std::atomic_bool fSuccessfullyConnected;
std::atomic_bool fDisconnect;
// We use fRelayTxes for two purposes -
// a) it allows us to not relay tx invs before receiving the peer's version message