| 326 | #endif |
| 327 | |
| 328 | static void GlobalInitializeOrDieImpl() { |
| 329 | ////////////////////////////////////////////////////////////////// |
| 330 | // Be careful about usages of gflags inside this function which // |
| 331 | // may be called before main() only seeing gflags with default // |
| 332 | // values even if the gflags will be set after main(). // |
| 333 | ////////////////////////////////////////////////////////////////// |
| 334 | |
| 335 | // Ignore SIGPIPE. |
| 336 | struct sigaction oldact; |
| 337 | if (sigaction(SIGPIPE, NULL, &oldact) != 0 || |
| 338 | (oldact.sa_handler == NULL && oldact.sa_sigaction == NULL)) { |
| 339 | CHECK(SIG_ERR != signal(SIGPIPE, SIG_IGN)); |
| 340 | } |
| 341 | |
| 342 | #if GOOGLE_PROTOBUF_VERSION < 3022000 |
| 343 | // Make GOOGLE_LOG print to comlog device |
| 344 | SetLogHandler(&BaiduStreamingLogHandler); |
| 345 | #endif |
| 346 | |
| 347 | if (bthread_set_span_funcs(CreateBthreadSpanAsVoid, |
| 348 | DestroyRpczParentSpan, |
| 349 | EndBthreadSpan) != 0) { |
| 350 | LOG(FATAL) << "Failed to register span callbacks to bthread"; |
| 351 | } |
| 352 | |
| 353 | // Setting the variable here does not work, the profiler probably check |
| 354 | // the variable before main() for only once. |
| 355 | // setenv("TCMALLOC_SAMPLE_PARAMETER", "524288", 0); |
| 356 | |
| 357 | // Initialize openssl library |
| 358 | SSL_library_init(); |
| 359 | // RPC doesn't require openssl.cnf, users can load it by themselves if needed |
| 360 | SSL_load_error_strings(); |
| 361 | if (SSLThreadInit() != 0 || SSLDHInit() != 0) { |
| 362 | exit(1); |
| 363 | } |
| 364 | |
| 365 | // Defined in http_rpc_protocol.cpp |
| 366 | InitCommonStrings(); |
| 367 | |
| 368 | // Leave memory of these extensions to process's clean up. |
| 369 | g_ext = new(std::nothrow) GlobalExtensions(); |
| 370 | if (NULL == g_ext) { |
| 371 | exit(1); |
| 372 | } |
| 373 | // Naming Services |
| 374 | #ifdef BAIDU_INTERNAL |
| 375 | NamingServiceExtension()->RegisterOrDie("bns", &g_ext->bns); |
| 376 | #endif |
| 377 | NamingServiceExtension()->RegisterOrDie("file", &g_ext->fns); |
| 378 | NamingServiceExtension()->RegisterOrDie("list", &g_ext->lns); |
| 379 | NamingServiceExtension()->RegisterOrDie("dlist", &g_ext->dlns); |
| 380 | NamingServiceExtension()->RegisterOrDie("http", &g_ext->dns); |
| 381 | NamingServiceExtension()->RegisterOrDie("https", &g_ext->dns_with_ssl); |
| 382 | NamingServiceExtension()->RegisterOrDie("redis", &g_ext->dns); |
| 383 | NamingServiceExtension()->RegisterOrDie("remotefile", &g_ext->rfns); |
| 384 | NamingServiceExtension()->RegisterOrDie("consul", &g_ext->cns); |
| 385 | NamingServiceExtension()->RegisterOrDie("discovery", &g_ext->dcns); |
nothing calls this directly
no test coverage detected