message: Fix AddrMan locking
diff: @@ -480,6 +480,7 @@ public:
  //! Return the number of (unique) addresses in all tables.
  int size()
  {
  + LOCK(cs); // TODO: Cache this in an atomic to avoid this overhead
  return vRandom.size();
  }
  @@ -498,14 +499,12 @@ public:
  //! Add a single address.
  bool Add(const CAddress& addr, const CNetAddr& source, int64_t nTimePenalty = 0)
  - {
  - bool fRet = false;
  {
  LOCK(cs);
  + bool fRet = false;
  Check();
  fRet |= Add_(addr, source, nTimePenalty);
  Check();
  - }
  if (fRet)
  LogPrint(BCLog::ADDRMAN, "Added %s from %s: %i tried, %i new\n", addr.ToStringIPPort(), source.ToString(), nTried, nNew);
  return fRet;
  @@ -513,15 +512,13 @@ public:
  //! Add multiple addresses.
  bool Add(const std::vector<CAddress>& vAddr, const CNetAddr& source, int64_t nTimePenalty = 0)
  - {
  - int nAdd = 0;
  {
  LOCK(cs);
  + int nAdd = 0;
  Check();
  for (std::vector<CAddress>::const_iterator it = vAddr.begin(); it != vAddr.end(); it++)
  nAdd += Add_(*it, source, nTimePenalty) ? 1 : 0;
  Check();
  - }
  if (nAdd)
  LogPrint(BCLog::ADDRMAN, "Added %i addresses from %s: %i tried, %i new\n", nAdd, source.ToString(), nTried, nNew);
  return nAdd > 0;
  