diff --git a/tools/rpc_replay/rpc_replay.cpp b/tools/rpc_replay/rpc_replay.cpp index a08fbefa1c..412397b29c 100644 --- a/tools/rpc_replay/rpc_replay.cpp +++ b/tools/rpc_replay/rpc_replay.cpp @@ -29,6 +29,7 @@ #include #include #include +#include "brpc/options.pb.h" #include "info_thread.h" DEFINE_string(dir, "", "The directory of dumped requests"); @@ -82,21 +83,25 @@ int ChannelGroup::Init() { } _chans.resize(max_protocol_size + 1); for (size_t i = 0; i < protocols.size(); ++i) { - if (protocols[i].second.support_client() && - protocols[i].second.support_server()) { - const brpc::ProtocolType prot = protocols[i].first; + const brpc::ProtocolType protocol_type = protocols[i].first; + const brpc::Protocol protocol = protocols[i].second; + brpc::ChannelOptions options; + options.protocol = protocol_type; + options.connection_type = FLAGS_connection_type; + options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; + options.max_retry = FLAGS_max_retry; + if ((options.connection_type == brpc::CONNECTION_TYPE_UNKNOWN || + options.connection_type & protocol.supported_connection_type) && + protocol.support_client() && + protocol.support_server()) { brpc::Channel* chan = new brpc::Channel; - brpc::ChannelOptions options; - options.protocol = prot; - options.connection_type = FLAGS_connection_type; - options.timeout_ms = FLAGS_timeout_ms/*milliseconds*/; - options.max_retry = FLAGS_max_retry; if (chan->Init(FLAGS_server.c_str(), FLAGS_load_balancer.c_str(), &options) != 0) { LOG(ERROR) << "Fail to initialize channel"; + delete chan; return -1; } - _chans[prot] = chan; + _chans[protocol_type] = chan; } } return 0;