sociomantic-tsunami / dhtproto

Distributed Hash Table protocol definition, client, fake node, and tests
Boost Software License 1.0
5 stars 22 forks source link

The example in DhtClient.d doesn't work with Neo (events still registered with epoll) #216

Open don-clugston-sociomantic opened 5 years ago

don-clugston-sociomantic commented 5 years ago

The example in src/dhtproto/client/DhtClient.d is essentially

        // Initialise dht client -- Step 2
        auto dht = new DhtClient(epoll, NumConnections);

        // Add nodes -- Step 3
        ...
        // Perform node handshake -- Step 4
        dht.nodeHandshake(&handshake, &notify);
        epoll.eventLoop();

        // Perform a Get request -- Step 5
        dht.assign(dht.get("my_channel", key, &receive_value, &notify));

However, step 5 will never be reached. The reason is that nodeHandshake() leaves events registered with epoll (they are all of the form 10: ConnectProtocol fd=177 events=ReRh, I think they are listening for read events on each node?) So eventLoop() never returns.

don-clugston-sociomantic commented 5 years ago

The example in dhtproto/src/dhtproto/client/UsageExamples.d instead calls dht.blocking.waitAllHashRangesKnown() which can only be run from inside a Task and is therefore conceptually completely different. Both DmqNeo and DlsNeo are usable without Tasks. If DhtNeo requires Tasks, that should be stated somewhere.