Skip to content

Commit 85c3ac2

Browse files
committed
review code
1 parent db27dd3 commit 85c3ac2

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

src/brpc/channel.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ ChannelSSLOptions* ChannelOptions::mutable_ssl_options() {
7878
static ChannelSignature ComputeChannelSignature(const ChannelOptions& opt) {
7979
if (opt.auth == NULL &&
8080
!opt.has_ssl_options() &&
81+
opt.client_host.empty() &&
82+
opt.device_name.empty() &&
8183
opt.connection_group.empty() &&
8284
opt.hc_option.health_check_path.empty()) {
8385
// Returning zeroized result by default is more intuitive for users.
@@ -95,6 +97,14 @@ static ChannelSignature ComputeChannelSignature(const ChannelOptions& opt) {
9597
buf.append("|conng=");
9698
buf.append(opt.connection_group);
9799
}
100+
if (!opt.client_host.empty()) {
101+
buf.append("|clih=");
102+
buf.append(opt.client_host);
103+
}
104+
if (!opt.device_name.empty()) {
105+
buf.append("|devn=");
106+
buf.append(opt.device_name);
107+
}
98108
if (opt.auth) {
99109
buf.append("|auth=");
100110
buf.append((char*)&opt.auth, sizeof(opt.auth));

src/brpc/rdma_transport.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ ssize_t RdmaTransport::CutFromIOBufList(butil::IOBuf **buf, size_t ndata) {
8989
if (_rdma_ep && _rdma_state != RDMA_OFF) {
9090
return _rdma_ep->CutFromIOBufList(buf, ndata);
9191
}
92-
return butil::IOBuf::cut_multiple_into_file_descriptor(_socket->fd(), buf, ndata);
92+
return _tcp_transport->CutFromIOBufList(buf, ndata);
9393
}
9494

9595
int RdmaTransport::WaitEpollOut(butil::atomic<int> *_epollout_butex,
@@ -104,8 +104,10 @@ int RdmaTransport::WaitEpollOut(butil::atomic<int> *_epollout_butex,
104104
if (errno != EAGAIN && errno != ETIMEDOUT) {
105105
const int saved_errno = errno;
106106
PLOG(WARNING) << "Fail to wait rdma window of " << _socket;
107-
_socket->SetFailed(saved_errno, "Fail to wait rdma window of %s: %s",
108-
_socket->description().c_str(), berror(saved_errno));
107+
_socket->SetFailed(saved_errno,
108+
"Fail to wait rdma window of %s: %s",
109+
_socket->description().c_str(),
110+
berror(saved_errno));
109111
}
110112
if (_socket->Failed()) {
111113
// NOTE:
@@ -114,7 +116,7 @@ int RdmaTransport::WaitEpollOut(butil::atomic<int> *_epollout_butex,
114116
// is already failed here.
115117
return 1;
116118
}
117-
}
119+
}
118120
}
119121
} else {
120122
return _tcp_transport->WaitEpollOut(_epollout_butex, pollin, duetime);

src/brpc/socket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ Socket::Socket(Forbidden f)
474474
, _ssl_state(SSL_UNKNOWN)
475475
, _ssl_session(NULL)
476476
, _socket_mode(SOCKET_MODE_TCP)
477-
, _transport(NULL)
477+
, _transport(nullptr)
478478
, _connection_type_for_progressive_read(CONNECTION_TYPE_UNKNOWN)
479479
, _controller_released_socket(false)
480480
, _overcrowded(false)
@@ -2203,7 +2203,7 @@ int Socket::OnInputEvent(void* user_data, uint32_t events,
22032203
g_vars->neventthread << 1;
22042204

22052205
// transfer ownership as well, don't use s anymore!
2206-
Socket *const p = s.release();
2206+
Socket* const p = s.release();
22072207

22082208
bthread_attr_t attr = thread_attr;
22092209
attr.keytable_pool = p->_keytable_pool;

src/brpc/transport_factory.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,11 @@ int TransportFactory::ContextInitOrDie(SocketMode mode, bool serverOrNot, const
3636

3737
std::shared_ptr<Transport> TransportFactory::CreateTransport(SocketMode mode) {
3838
if (mode == SOCKET_MODE_TCP) {
39-
// 使用共享指针创建对象
40-
return std::make_shared<TcpTransport>();
39+
return std::unique_ptr<TcpTransport>(new TcpTransport());
4140
}
4241
#if BRPC_WITH_RDMA
4342
else if (mode == SOCKET_MODE_RDMA) {
44-
return std::make_shared<RdmaTransport>();
43+
return std::unique_ptr<RdmaTransport>(new RdmaTransport());
4544
}
4645
#endif
4746
else {

0 commit comments

Comments
 (0)