You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ww...@apache.org on 2022/10/08 07:11:24 UTC

[incubator-brpc] branch master updated: fix(rpc_replay) continue when failed to init channel (#1938)

This is an automated email from the ASF dual-hosted git repository.

wwbmmm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 5a6d99a5 fix(rpc_replay) continue when failed to init channel (#1938)
5a6d99a5 is described below

commit 5a6d99a54ca7787116334bf5f94f460977491ac7
Author: ds <eh...@qq.com>
AuthorDate: Sat Oct 8 15:11:18 2022 +0800

    fix(rpc_replay) continue when failed to init channel (#1938)
    
    * fix(rpc_replay) continue when failed to init channel
    
    * check supported_connection_type
    
    * check supported_connection_type
    
    * check supported_connection_type
    
    * fix lint
---
 tools/rpc_replay/rpc_replay.cpp | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/tools/rpc_replay/rpc_replay.cpp b/tools/rpc_replay/rpc_replay.cpp
index a08fbefa..412397b2 100644
--- a/tools/rpc_replay/rpc_replay.cpp
+++ b/tools/rpc_replay/rpc_replay.cpp
@@ -29,6 +29,7 @@
 #include <brpc/serialized_request.h>
 #include <brpc/nshead_message.h>
 #include <brpc/details/http_message.h>
+#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;


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org