Browse Source

don't try to save RouterInfo if no buffer

pull/1879/head
orignal 2 years ago
parent
commit
c2faa5c614
  1. 8
      libi2pd/NetDb.cpp
  2. 2
      libi2pd/RouterInfo.h

8
libi2pd/NetDb.cpp

@ -279,6 +279,7 @@ namespace data
if (!r->Update (buf, len)) if (!r->Update (buf, len))
{ {
updated = false; updated = false;
m_Requests.RequestComplete (ident, r);
return r; return r;
} }
if (r->IsUnreachable ()) if (r->IsUnreachable ())
@ -290,6 +291,7 @@ namespace data
std::unique_lock<std::mutex> l(m_FloodfillsMutex); std::unique_lock<std::mutex> l(m_FloodfillsMutex);
m_Floodfills.remove (r); m_Floodfills.remove (r);
} }
m_Requests.RequestComplete (ident, nullptr);
return nullptr; return nullptr;
} }
} }
@ -645,10 +647,14 @@ namespace data
std::string ident = it.second->GetIdentHashBase64(); std::string ident = it.second->GetIdentHashBase64();
if (it.second->IsUpdated ()) if (it.second->IsUpdated ())
{ {
if (it.second->GetBuffer ())
{
// we have something to save
it.second->SaveToFile (m_Storage.Path(ident)); it.second->SaveToFile (m_Storage.Path(ident));
it.second->SetUpdated (false);
it.second->SetUnreachable (false); it.second->SetUnreachable (false);
it.second->DeleteBuffer (); it.second->DeleteBuffer ();
}
it.second->SetUpdated (false);
updatedCount++; updatedCount++;
continue; continue;
} }

2
libi2pd/RouterInfo.h

@ -242,7 +242,7 @@ namespace data
void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; }; void SetUnreachable (bool unreachable) { m_IsUnreachable = unreachable; };
bool IsUnreachable () const { return m_IsUnreachable; }; bool IsUnreachable () const { return m_IsUnreachable; };
const uint8_t * GetBuffer () const { return m_Buffer->data (); }; const uint8_t * GetBuffer () const { return m_Buffer ? m_Buffer->data () : nullptr; };
const uint8_t * LoadBuffer (const std::string& fullPath); // load if necessary const uint8_t * LoadBuffer (const std::string& fullPath); // load if necessary
size_t GetBufferLen () const { return m_BufferLen; }; size_t GetBufferLen () const { return m_BufferLen; };

Loading…
Cancel
Save