(原創)C/C++語言, 平臺是debian10, grpc版本:grpc-c++/1.25.0-dev grpc-c/8.0.0, 使用的例子是自帶的例子GreeterClient
創建 default-executor 和 resolver-executor 執行緒的主要流程,創建channel時會創建這2個執行緒
graph TD; 000(grpc::InsecureChannelCredentials #credentials.h:91 呼叫InsecureChannelCredentials)-->001(grpc_impl::InsecureChannelCredentials #insecure_credentials.cc:59 創建一個共享的InsecureChannelCredentialsImpl物件) 001-->002(grpc_impl::InsecureChannelCredentialsImpl::InsecureChannelCredentialsImpl #insecure_credentials.cc:30 呼叫父類ChannelCredentials建構式) 002-->003(grpc_impl::ChannelCredentials::ChannelCredentials #credentials_cc.cc:25 呼叫父類GrpcLibraryCodegen建構式) 003-->004(grpc::GrpcLibraryCodegen::GrpcLibraryCodegen #grpc_library.h:45 呼叫GrpcLibraryInterface的init) 004-->005(grpc::internal::GrpcLibrary::init #grpc_library.h:34 呼叫grpc_init) 005-->006(grpc_init #init.cc:146 呼叫grpc_iomgr_init) 006-->007(grpc_iomgr_init #iomgr.cc:60 呼叫grpc_core::Executor::InitAll) 007-->008(創建 default-executor 和 resolver-executor 執行緒) 008-->009(grpc_iomgr_start #iomgr.cc:69 呼叫grpc_timer_manager_init) 009-->010(grpc_timer_manager_init #timer_manager.cc:311 呼叫start_threads) 010-->011(start_threads #timer_manager.cc:293 呼叫start_timer_thread_and_unlock) 011-->012(start_timer_thread_and_unlock #timer_manager.cc:91 啟動grpc_global_timer執行緒)grpc Unary模式下客戶端啟動到執行grpc_connector_connect的主要流程
graph TD; 000(grpc::internal::BlockingUnaryCall #client_unary_call.h:43)-->001(grpc::internal::BlockingUnaryCallImpl::BlockingUnaryCallImpl #client_unary_call.h:71 創建CompletionQueue, Call, CallOpSet物件, 設定CallOpSet物件引數, 呼叫PerformOps) 001-->002(grpc::internal::Call::PerformOps #call.h:69 呼叫PerformOpsOnCall) 002-->003(grpc_impl::Channel::PerformOpsOnCall #channel_cc.cc:164 呼叫FillOps) 003-->004(grpc::internal::CallOpSet::FillOps #call_op_set.h:874 呼叫ContinueFillOpsAfterInterception) 004-->005(grpc::internal::CallOpSet::ContinueFillOpsAfterInterception #call_op_set.h:943 呼叫6個op的AddOp并呼叫grpc_call_start_batch) 005-->006(grpc::CoreCodegen::grpc_call_start_batch #core_codegen.cc:113 呼叫grpc_call_start_batch) 006-->007(grpc_call_start_batch #call.cc:1974 呼叫call_start_batch) 007-->008(call_start_batch #call.cc:1929 根據6個ops的op->op, 設定stream_op, ops, call的引數, 最后呼叫execute_batch) 008-->009(execute_batch #call.cc:639 呼叫start_batch_closure的callback函式 execute_batch_in_call_combiner) 009-->010(execute_batch_in_call_combiner #call.cc:628 呼叫 elem->filter->start_transport_stream_op_batch) 010-->011(grpc_call_next_op #channel_stack.cc:227 呼叫 next_elem->filter->start_transport_stream_op_batch) 011-->012(grpc_core::CallData::StartTransportStreamOpBatch #client_channel.cc:2140 把batch加入pending:PendingBatchesAdd并呼叫PickSubchannel) 012-->013(grpc_core::CallData::PickSubchannel #client_channel.cc:3853 呼叫PickSubchannelLocked回傳false) 013-->014(grpc_core::CallData::PickSubchannelLocked #client_channel.cc:3870 picker_是nullptr, 呼叫CheckConnectivityState, 引數設定為嘗試連接) 014-->015(grpc_core::ChannelData::CheckConnectivityState #client_channel.cc:1956 創建closure并呼叫它的callback函式 TryToConnectLocked) 015-->016(closure_impl::closure_wrapper #closure.h:156 創建closure是callback函式是closure_impl::closure_wrapper, 真正的callback是 TryToConnectLocked) 016-->017(grpc_core::ChannelData::TryToConnectLocked #client_channel.cc:1946 呼叫CreateResolvingLoadBalancingPolicyLocked) 017-->018(grpc_core::ChannelData::CreateResolvingLoadBalancingPolicyLocked #client_channel.cc:1596 呼叫ResolvingLoadBalancingPolicy建構式) 018-->019(grpc_core::ResolvingLoadBalancingPolicy #resolving_lb_policy.cc:199 創建CreateResolver, UpdateState并呼叫StartLocked開始決議) 019-->020(grpc_core::AresDnsResolver::StartLocked #dns_resolver_ares.cc:177 呼叫MaybeStartResolvingLocked) 020-->021(grpc_core::AresDnsResolver::MaybeStartResolvingLocked #dns_resolver_ares.cc:409 呼叫StartResolvingLocked) 021-->022(grpc_core::AresDnsResolver::StartResolvingLocked #dns_resolver_ares.cc:420 呼叫grpc_dns_lookup_ares_locked) 022-->023(grpc_dns_lookup_ares_locked_impl #grpc_ares_wrapper.cc:625 呼叫grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked) 023-->024(grpc_dns_lookup_ares_continue_after_check_localhost_and_ip_literals_locked #grpc_ares_wrapper.cc:446 使用c-ares通過dns查找ip地址, 最后呼叫grpc_ares_request_unref_locked) 024-->025(grpc_ares_request_unref_locked #grpc_ares_wrapper.cc:135 如果延遲的查詢為0, 呼叫grpc_ares_ev_driver_on_queries_complete_locked) 025-->026(grpc_ares_ev_driver_on_queries_complete_locked #grpc_ares_ev_driver.cc:191 停止查詢,呼叫grpc_timer_cancel, 引數是query_timeout) 026-->027(grpc_timer_cancel #timer.cc:35 呼叫grpc_timer_impl->cancel) 027-->028(timer_cancel #timer_generic.cc:474 呼叫 timer->closure對應的callback函式) 028-->029(on_ares_backup_poll_alarm_locked #grpc_ares_ev_driver.cc:288 呼叫grpc_ares_ev_driver_unref) 029-->030(grpc_ares_ev_driver_unref #grpc_ares_ev_driver.cc:112 釋放資源并呼叫grpc_ares_complete_request_locked) 030-->031(grpc_ares_complete_request_locked #grpc_ares_wrapper.cc:151 呼叫on_done對應的callback函式) 031-->032(grpc_core::AresDnsResolver::OnResolvedLocked #dns_resolver_ares.cc:347 決議完成, 呼叫ReturnResult) 032-->033(grpc_core::ResolvingLoadBalancingPolicy::ResolverResultHandler::ReturnResult #resolving_lb_policy.cc:87 呼叫OnResolverResultChangedLocked) 033-->034(OnResolverResultChangedLocked #resolving_lb_policy.cc:479 獲得lb_policy_name,默認pick_first, 如果lb_policy_name不為空, 則創建或者更新LB policy, 呼叫的是CreateOrUpdateLbPolicyLocked) 034-->035(CreateOrUpdateLbPolicyLocked #resolving_lb_policy.cc:364 創建或者更新lb_policy, 呼叫UpdateLocked) 035-->036(PickFirst::UpdateLocked #pick_first.cc:280 呼叫AttemptToConnectUsingLatestUpdateArgsLocked) 036-->037(PickFirst::AttemptToConnectUsingLatestUpdateArgsLocked #pick_first.cc:236 用latest_update_args_創建 subchannel串列, 如果串列中的subchannel有狀態是GRPC_CHANNEL_READY, 則選中此subchannel, 否則選中第0個subchannel) 037-->038(AttemptToConnect #client_channel.cc:921 呼叫subchannel_->AttemptToConnect) 038-->039(Subchannel::AttemptToConnect #subchannel.cc:823 呼叫MaybeStartConnectingLocked) 039-->040(Subchannel::MaybeStartConnectingLocked #subchannel.cc:930 呼叫ContinueConnectingLocked) 040-->041(Subchannel::ContinueConnectingLocked #subchannel.cc:983 設定grpc_connect_in_args引數并呼叫grpc_connector_connect, 通過connector->vtable->connect最后呼叫chttp2_connector_connect)轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/91718.html
標籤:C++
上一篇:記錄一次gdb debug經歷
