| 63 | |
| 64 | std::string description() const override { return name; } |
| 65 | ACTOR static Future<Void> _setup(UDPWorkload* self, Database cx) { |
| 66 | state NetworkAddress localAddress(g_network->getLocalAddress().ip, |
| 67 | deterministicRandom()->randomInt(self->minPort, self->maxPort + 1), |
| 68 | true, |
| 69 | false); |
| 70 | state Key key = self->keyPrefix.withSuffix(BinaryWriter::toValue(self->clientId, Unversioned())); |
| 71 | state Value serializedLocalAddress = BinaryWriter::toValue(localAddress, IncludeVersion()); |
| 72 | state ReadYourWritesTransaction tr(cx); |
| 73 | Reference<IUDPSocket> s = wait(INetworkConnections::net()->createUDPSocket(localAddress.isV6())); |
| 74 | self->serverSocket = std::move(s); |
| 75 | self->serverSocket->bind(localAddress); |
| 76 | self->serverAddress = localAddress; |
| 77 | loop { |
| 78 | try { |
| 79 | Optional<Value> v = wait(tr.get(key)); |
| 80 | if (v.present()) { |
| 81 | return Void(); |
| 82 | } |
| 83 | tr.set(key, serializedLocalAddress); |
| 84 | wait(tr.commit()); |
| 85 | return Void(); |
| 86 | } catch (Error& e) { |
| 87 | wait(tr.onError(e)); |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | Future<Void> setup(Database const& cx) override { return _setup(this, cx); } |
| 92 | |
| 93 | class Message { |
nothing calls this directly
no test coverage detected