Browse Source

fix the fix

cl-refactor
subtly 10 years ago
parent
commit
46a286f6e7
  1. 4
      libp2p/UDP.h
  2. 16
      test/net.cpp

4
libp2p/UDP.h

@ -37,6 +37,8 @@ namespace p2p
struct UDPDatagram
{
UDPDatagram() = default;
UDPDatagram(bi::udp::endpoint _ep, bytes _data): to(_ep), data(std::move(_data)) {}
bi::udp::endpoint to;
bytes data;
};
@ -167,7 +169,7 @@ protected:
std::atomic<bool> m_closed; ///< Set when connection is stopping or stopped. Handshake cannot occur unless m_closed is true.
std::atomic<bool> m_started; ///< Atomically ensure connection is started once. Start cannot occur unless m_started is false. Managed by start and disconnectWithError.
Handler& m_host; ///< Interface which owns this socket.
UDPSocketEvents& m_host; ///< Interface which owns this socket.
Mutex x_sendQ;
std::deque<UDPDatagram> sendQ;

16
test/net.cpp

@ -20,6 +20,7 @@
*/
#include <boost/test/unit_test.hpp>
#include <libdevcrypto/Common.h>
#include <libdevcore/Worker.h>
#include <libp2p/UDP.h>
using namespace std;
@ -28,21 +29,6 @@ using namespace dev::p2p;
namespace ba = boost::asio;
namespace bi = ba::ip;
class Kademlia: UDPSocketEvents
{
public:
Kademlia(): Worker("test",0), m_io(), m_socket(new UDPSocket<Kademlia, 1024>(m_io, *this, 30300)) {}
~Kademlia() { m_io.stop(); stopWorking(); }
void onDisconnected(UDPSocketFace*) {};
void onReceived(UDPSocketFace*, bi::udp::endpoint const& _from, bytesConstRef _packet) { if (_packet.toString() == "AAAA") success = true; }
ba::io_service m_io;
shared_ptr<UDPSocket<Kademlia, 1024>> m_socket;
bool success = false;
};
class TestA: UDPSocketEvents, public Worker
{
public:

Loading…
Cancel
Save