MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3 / start_thread

Function start_thread

test/ovpncli/cli.cpp:407–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

405#if defined(OPENVPN_PLATFORM_WIN)
406
407static void start_thread(Client& client)
408{
409 // Set Windows title bar
410 const std::string title_text = "F2:Stats F3:Reconnect F4:Stop F5:Pause";
411 Win::Console::Title title(ClientAPI::OpenVPNClient::platform() + " " + title_text);
412 Win::Console::Input console;
413
414 // start connect thread
415 std::unique_ptr<std::thread> thread;
416 volatile bool thread_exit = false;
417 the_client = &client;
418 thread.reset(new std::thread([&thread_exit]() {
419 worker_thread();
420 thread_exit = true;
421 }));
422
423 // wait for connect thread to exit, also check for keypresses
424 while (!thread_exit)
425 {
426 while (true)
427 {
428 const unsigned int c = console.get();
429 if (!c)
430 break;
431 else if (c == 0x3C) // F2
432 the_client->print_stats();
433 else if (c == 0x3D) // F3
434 the_client->reconnect(0);
435 else if (c == 0x3E) // F4
436 the_client->stop();
437 else if (c == 0x3F) // F5
438 the_client->pause("user-pause");
439 }
440 Sleep(1000);
441 }
442
443 // wait for connect thread to exit
444 thread->join();
445
446 the_client = nullptr;
447}
448
449#elif defined(OPENVPN_OVPNCLI_SINGLE_THREAD)
450

Callers 1

openvpn_clientFunction · 0.85

Calls 8

worker_threadFunction · 0.85
print_statsMethod · 0.80
resetMethod · 0.45
getMethod · 0.45
reconnectMethod · 0.45
stopMethod · 0.45
pauseMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected