| 87 | } |
| 88 | |
| 89 | bool DHTEntryPointNameResolveCommand::execute() |
| 90 | { |
| 91 | if (e_->getRequestGroupMan()->downloadFinished() || e_->isHaltRequested()) { |
| 92 | return true; |
| 93 | } |
| 94 | try { |
| 95 | #ifdef ENABLE_ASYNC_DNS |
| 96 | if (e_->getOption()->getAsBool(PREF_ASYNC_DNS)) { |
| 97 | while (!entryPoints_.empty()) { |
| 98 | std::string hostname = entryPoints_.front().first; |
| 99 | std::vector<std::string> res; |
| 100 | int rv = resolveHostname(res, hostname); |
| 101 | if (rv == 0) { |
| 102 | e_->addCommand(std::unique_ptr<Command>(this)); |
| 103 | return false; |
| 104 | } |
| 105 | else { |
| 106 | if (rv == 1) { |
| 107 | ++numSuccess_; |
| 108 | std::pair<std::string, uint16_t> p(res.front(), |
| 109 | entryPoints_.front().second); |
| 110 | addPingTask(p); |
| 111 | } |
| 112 | asyncNameResolverMan_->reset(e_, this); |
| 113 | } |
| 114 | entryPoints_.pop_front(); |
| 115 | } |
| 116 | } |
| 117 | else |
| 118 | #endif // ENABLE_ASYNC_DNS |
| 119 | { |
| 120 | NameResolver res; |
| 121 | res.setSocktype(SOCK_DGRAM); |
| 122 | res.setFamily(family_); |
| 123 | while (!entryPoints_.empty()) { |
| 124 | std::string hostname = entryPoints_.front().first; |
| 125 | try { |
| 126 | std::vector<std::string> addrs; |
| 127 | res.resolve(addrs, hostname); |
| 128 | |
| 129 | ++numSuccess_; |
| 130 | std::pair<std::string, uint16_t> p(addrs.front(), |
| 131 | entryPoints_.front().second); |
| 132 | addPingTask(p); |
| 133 | } |
| 134 | catch (RecoverableException& e) { |
| 135 | A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, e); |
| 136 | } |
| 137 | entryPoints_.pop_front(); |
| 138 | } |
| 139 | } |
| 140 | if (bootstrapEnabled_ && numSuccess_) { |
| 141 | taskQueue_->addPeriodicTask1( |
| 142 | taskFactory_->createNodeLookupTask(localNode_->getID())); |
| 143 | taskQueue_->addPeriodicTask1(taskFactory_->createBucketRefreshTask()); |
| 144 | } |
| 145 | } |
| 146 | catch (RecoverableException& e) { |
nothing calls this directly
no test coverage detected