MCPcopy Create free account
hub / github.com/ElementsProject/elements / DispatchMapPort

Function DispatchMapPort

src/mapport.cpp:268–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268static void DispatchMapPort()
269{
270 if (g_mapport_current_proto == MapPortProtoFlag::NONE && g_mapport_enabled_protos == MapPortProtoFlag::NONE) {
271 return;
272 }
273
274 if (g_mapport_current_proto == MapPortProtoFlag::NONE && g_mapport_enabled_protos != MapPortProtoFlag::NONE) {
275 StartThreadMapPort();
276 return;
277 }
278
279 if (g_mapport_current_proto != MapPortProtoFlag::NONE && g_mapport_enabled_protos == MapPortProtoFlag::NONE) {
280 InterruptMapPort();
281 StopMapPort();
282 return;
283 }
284
285 if (g_mapport_enabled_protos & g_mapport_current_proto) {
286 // Enabling another protocol does not cause switching from the currently used one.
287 return;
288 }
289
290 assert(g_mapport_thread.joinable());
291 assert(!g_mapport_interrupt);
292 // Interrupt a protocol-specific loop in the ThreadUpnp() or in the ThreadNatpmp()
293 // to force trying the next protocol in the ThreadMapPort() loop.
294 g_mapport_interrupt();
295}
296
297static void MapPortProtoSetEnabled(MapPortProtoFlag proto, bool enabled)
298{

Callers 1

StartMapPortFunction · 0.85

Calls 3

StartThreadMapPortFunction · 0.85
InterruptMapPortFunction · 0.85
StopMapPortFunction · 0.85

Tested by

no test coverage detected