Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
chenBright committed Apr 1, 2024
1 parent 6bcd261 commit 23c0d3e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/brpc/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/brpc/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/socket_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/brpc_ssl_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 23c0d3e

Please sign in to comment.