From 23c0d3eb68864802919a2ccd083631929099dd17 Mon Sep 17 00:00:00 2001 From: Bright Chen Date: Tue, 19 Mar 2024 21:48:54 +0800 Subject: [PATCH] Rename --- src/brpc/socket.cpp | 8 ++++++-- src/brpc/socket.h | 4 ++-- src/brpc/socket_inl.h | 2 +- test/brpc_ssl_unittest.cpp | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/brpc/socket.cpp b/src/brpc/socket.cpp index 4e35284df5..95d1c7ed4e 100644 --- a/src/brpc/socket.cpp +++ b/src/brpc/socket.cpp @@ -541,6 +541,10 @@ int Socket::ResetFileDescriptor(int fd) { if (!ValidFileDescriptor(fd)) { return 0; } + if (_remote_side == butil::EndPoint()) { + // OK to fail, non-socket fd does not support this. + butil::get_remote_side(fd, &_remote_side); + } // OK to fail, non-socket fd does not support this. if (butil::get_local_side(fd, &_local_side) != 0) { _local_side = butil::EndPoint(); @@ -748,8 +752,8 @@ int Socket::Create(const SocketOptions& options, SocketId* id) { CHECK(NULL == m->_write_head.load(butil::memory_order_relaxed)); int fd = options.fd; if (!m->ValidFileDescriptor(fd) && options.connect_on_create) { - // Connect on created. - fd = m->DoConnect(options.abstime, NULL, NULL); + // Connect on create. + fd = m->DoConnect(options.connect_abstime, NULL, NULL); if (fd < 0) { PLOG(ERROR) << "Fail to connect to " << options.remote_side; int error_code = errno != 0 ? errno : EHOSTDOWN; diff --git a/src/brpc/socket.h b/src/brpc/socket.h index 945edf4827..3c389087dc 100644 --- a/src/brpc/socket.h +++ b/src/brpc/socket.h @@ -200,12 +200,12 @@ struct SocketOptions { butil::EndPoint remote_side; // If `connect_on_create' is true and `fd' is less than 0, // a client connection will be established to remote_side() - // regarding deadline `abstime' when Socket is being created. + // regarding deadline `connect_abstime' when Socket is being created. // Default: false, means that a connection will be established // on first write. bool connect_on_create; // Default: NULL, means no timeout. - const timespec* abstime; + const timespec* connect_abstime; SocketUser* user; // When *edge-triggered* events happen on the file descriptor, callback // `on_edge_triggered_events' will be called. Inside the callback, user diff --git a/src/brpc/socket_inl.h b/src/brpc/socket_inl.h index 65c48af645..cc77215ea1 100644 --- a/src/brpc/socket_inl.h +++ b/src/brpc/socket_inl.h @@ -55,7 +55,7 @@ BUTIL_FORCE_INLINE uint64_t MakeVRef(uint32_t version, int32_t nref) { inline SocketOptions::SocketOptions() : fd(-1) , connect_on_create(false) - , abstime(NULL) + , connect_abstime(NULL) , user(NULL) , on_edge_triggered_events(NULL) , health_check_interval_s(-1) diff --git a/test/brpc_ssl_unittest.cpp b/test/brpc_ssl_unittest.cpp index efaca2e801..3c64ba765b 100644 --- a/test/brpc_ssl_unittest.cpp +++ b/test/brpc_ssl_unittest.cpp @@ -244,7 +244,7 @@ void ProcessResponse(brpc::InputMessageBase* msg_base) { ASSERT_EQ(0, bthread_id_unlock_and_destroy(cid)); } -TEST_F(SSLTest, fd_ssl) { +TEST_F(SSLTest, connect_on_create) { brpc::Protocol dummy_protocol = { brpc::policy::ParseRpcMessage, brpc::SerializeRequestDefault, brpc::policy::PackRpcRequest,NULL, ProcessResponse,