| 266 | } |
| 267 | |
| 268 | static 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 | |
| 297 | static void MapPortProtoSetEnabled(MapPortProtoFlag proto, bool enabled) |
| 298 | { |
no test coverage detected