MCPcopy Create free account
hub / github.com/COVESA/vsomeip / routingmanagerd_process

Function routingmanagerd_process

examples/routingmanagerd/routingmanagerd.cpp:27–110  ·  view source on GitHub ↗

* Create a vsomeip application object and start it. */

Source from the content-addressed store, hash-verified

25 * Create a vsomeip application object and start it.
26 */
27int routingmanagerd_process(bool _is_quiet) {
28#ifdef USE_DLT
29 if (!_is_quiet)
30 DLT_REGISTER_APP(VSOMEIP_LOG_DEFAULT_APPLICATION_ID, VSOMEIP_LOG_DEFAULT_APPLICATION_NAME);
31#else
32 (void)_is_quiet;
33#endif
34
35 std::shared_ptr<vsomeip::runtime> its_runtime = vsomeip::runtime::get();
36
37 if (!its_runtime) {
38 return -1;
39 }
40
41 // Create the application object, and initialize it before sighandler thread starts
42 its_application = its_runtime->create_application("routingmanagerd");
43 if (!its_application->init()) {
44 its_application.reset();
45 return -1;
46 }
47
48#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
49
50 auto signal_worker_fn = []() {
51#if defined(__linux__) || defined(__QNX__)
52 pthread_setname_np(pthread_self(), "signal_w");
53#endif
54
55 // Unblock signals for this thread only
56 sigset_t handler_mask;
57 sigemptyset(&handler_mask);
58 sigaddset(&handler_mask, SIGUSR1);
59 sigaddset(&handler_mask, SIGUSR2);
60 sigaddset(&handler_mask, SIGTERM);
61 sigaddset(&handler_mask, SIGINT);
62 sigaddset(&handler_mask, SIGSEGV);
63 sigaddset(&handler_mask, SIGABRT);
64
65 while (true) {
66 int its_signal = 0;
67 sigwait(&handler_mask, &its_signal);
68
69 if (its_signal == SIGTERM || its_signal == SIGINT) {
70 its_application->stop();
71 return;
72 } else if (its_signal == SIGUSR1) {
73 its_application->set_routing_state(vsomeip::routing_state_e::RS_SUSPENDED);
74 } else if (its_signal == SIGUSR2) {
75 its_application->set_routing_state(vsomeip::routing_state_e::RS_RESUMED);
76 }
77 }
78 };
79
80 std::thread sighandler_thread(signal_worker_fn);
81#endif
82
83 if (its_application->is_routing()) {
84 its_application->start();

Callers 1

mainFunction · 0.85

Calls 11

get_idFunction · 0.85
create_applicationMethod · 0.80
detachMethod · 0.80
initMethod · 0.45
resetMethod · 0.45
stopMethod · 0.45
set_routing_stateMethod · 0.45
is_routingMethod · 0.45
startMethod · 0.45
get_idMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected