MCPcopy Create free account
hub / github.com/apple/foundationdb / rollRandomClose

Function rollRandomClose

fdbrpc/sim2.actor.cpp:436–460  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434 }
435
436 void rollRandomClose() {
437 // make sure connections between parenta and their childs are not closed
438 if (!stableConnection &&
439 now() - g_simulator.lastConnectionFailure > g_simulator.connectionFailuresDisableDuration &&
440 deterministicRandom()->random01() < .00001) {
441 g_simulator.lastConnectionFailure = now();
442 double a = deterministicRandom()->random01(), b = deterministicRandom()->random01();
443 CODE_PROBE(true, "Simulated connection failure", probe::context::sim2, probe::assert::simOnly);
444 TraceEvent("ConnectionFailure", dbgid)
445 .detail("MyAddr", process->address)
446 .detail("PeerAddr", peerProcess->address)
447 .detail("PeerIsValid", peer.isValid())
448 .detail("SendClosed", a > .33)
449 .detail("RecvClosed", a < .66)
450 .detail("Explicit", b < .3);
451 if (a < .66 && peer)
452 peer->closeInternal();
453 if (a > .33)
454 closeInternal();
455 // At the moment, we occasionally notice the connection failed immediately. In principle, this could happen
456 // but only after a delay.
457 if (b < .3)
458 throw connection_failed();
459 }
460 }
461
462 ACTOR static Future<Void> trackLeakedConnection(Sim2Conn* self) {
463 wait(g_simulator.onProcess(self->process));

Callers 2

readMethod · 0.85
writeMethod · 0.85

Calls 7

nowFunction · 0.85
deterministicRandomFunction · 0.85
TraceEventClass · 0.85
random01Method · 0.80
detailMethod · 0.80
isValidMethod · 0.45
closeInternalMethod · 0.45

Tested by

no test coverage detected