Browse Source

fixed race condition

pull/163/head
orignal 10 years ago
parent
commit
b11fd250c1
  1. 2
      I2NPProtocol.cpp
  2. 10
      NetDb.cpp

2
I2NPProtocol.cpp

@ -82,7 +82,7 @@ namespace i2p
I2NPMessage * CreateDeliveryStatusMsg (uint32_t msgID) I2NPMessage * CreateDeliveryStatusMsg (uint32_t msgID)
{ {
I2NPMessage * m = NewI2NPMessage (); I2NPMessage * m = NewI2NPShortMessage ();
uint8_t * buf = m->GetPayload (); uint8_t * buf = m->GetPayload ();
if (msgID) if (msgID)
{ {

10
NetDb.cpp

@ -131,7 +131,7 @@ namespace data
if (msg) if (msg)
{ {
int numMsgs = 0; int numMsgs = 0;
while (msg && numMsgs < 500) while (msg)
{ {
switch (msg->GetTypeID ()) switch (msg->GetTypeID ())
{ {
@ -151,6 +151,7 @@ namespace data
LogPrint ("NetDb: unexpected message type ", msg->GetTypeID ()); LogPrint ("NetDb: unexpected message type ", msg->GetTypeID ());
i2p::HandleI2NPMessage (msg); i2p::HandleI2NPMessage (msg);
} }
if (numMsgs > 100) break;
msg = m_Queue.Get (); msg = m_Queue.Get ();
numMsgs++; numMsgs++;
} }
@ -572,12 +573,12 @@ namespace data
auto pool = i2p::tunnel::tunnels.GetExploratoryPool (); auto pool = i2p::tunnel::tunnels.GetExploratoryPool ();
auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr; auto outbound = pool ? pool->GetNextOutboundTunnel () : nullptr;
auto inbound = pool ? pool->GetNextInboundTunnel () : nullptr; auto inbound = pool ? pool->GetNextInboundTunnel () : nullptr;
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
if (!dest->IsExploratory ()) if (!dest->IsExploratory ())
{ {
// reply to our destination. Try other floodfills // reply to our destination. Try other floodfills
if (outbound && inbound ) if (outbound && inbound )
{ {
std::vector<i2p::tunnel::TunnelMessageBlock> msgs;
auto count = dest->GetExcludedPeers ().size (); auto count = dest->GetExcludedPeers ().size ();
if (count < 7) if (count < 7)
{ {
@ -605,11 +606,12 @@ namespace data
} }
else else
LogPrint (key, " was not found on 7 floodfills"); LogPrint (key, " was not found on 7 floodfills");
if (msgs.size () > 0)
outbound->SendTunnelDataMsg (msgs);
} }
} }
if (outbound && msgs.size () > 0)
outbound->SendTunnelDataMsg (msgs);
if (deleteDest) if (deleteDest)
{ {
// no more requests for the destinationation. delete it // no more requests for the destinationation. delete it

Loading…
Cancel
Save