Skip to content

Commit

Permalink
fixed race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
orignal committed Jun 10, 2015
1 parent 09298d7 commit 0e8bdf8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions RouterContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@ namespace i2p
i2p::HandleI2NPMessage (CreateI2NPMessage (buf, GetI2NPMessageLength (buf), from));
}

void RouterContext::ProcessGarlicMessage (I2NPMessage * msg)
{
std::unique_lock<std::mutex> l(m_GarlicMutex);
i2p::garlic::GarlicDestination::ProcessGarlicMessage (msg);
}

void RouterContext::ProcessDeliveryStatusMessage (I2NPMessage * msg)
{
std::unique_lock<std::mutex> l(m_GarlicMutex);
i2p::garlic::GarlicDestination::ProcessDeliveryStatusMessage (msg);
}

uint32_t RouterContext::GetUptime () const
{
return i2p::util::GetSecondsSinceEpoch () - m_StartupTime;
Expand Down
6 changes: 6 additions & 0 deletions RouterContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <inttypes.h>
#include <string>
#include <memory>
#include <mutex>
#include <boost/asio.hpp>
#include <cryptopp/dsa.h>
#include <cryptopp/osrng.h>
Expand Down Expand Up @@ -75,6 +76,10 @@ namespace i2p
std::shared_ptr<const i2p::data::LeaseSet> GetLeaseSet () { return nullptr; };
std::shared_ptr<i2p::tunnel::TunnelPool> GetTunnelPool () const;
void HandleI2NPMessage (const uint8_t * buf, size_t len, std::shared_ptr<i2p::tunnel::InboundTunnel> from);

// override GarlicDestination
void ProcessGarlicMessage (I2NPMessage * msg);
void ProcessDeliveryStatusMessage (I2NPMessage * msg);

private:

Expand All @@ -93,6 +98,7 @@ namespace i2p
bool m_AcceptsTunnels, m_IsFloodfill;
uint64_t m_StartupTime; // in seconds since epoch
RouterStatus m_Status;
std::mutex m_GarlicMutex;
};

extern RouterContext context;
Expand Down

0 comments on commit 0e8bdf8

Please sign in to comment.