Skip to content

Commit

Permalink
r35386: Add more errors to does_error_affect_main_socket
Browse files Browse the repository at this point in the history
  • Loading branch information
gejun committed Oct 18, 2017
1 parent fe899cb commit 3a2dee2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/brpc/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,8 @@ void* Controller::RunEndRPC(void* arg) {

inline bool does_error_affect_main_socket(int error_code) {
return error_code == ECONNREFUSED ||
error_code == ENETUNREACH ||
error_code == EHOSTUNREACH ||
error_code == EINVAL/*returned by connect "0.0.0.1"*/;
}

Expand Down
4 changes: 2 additions & 2 deletions src/brpc/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ void Socket::AfterAppConnected(int err, void* data) {
}
} else {
SocketUniquePtr s(req->socket);
s->SetFailed(err, "Fail to make %s connected: %s",
s->SetFailed(err, "Fail to connect %s: %s",
s->description().c_str(), berror(err));
s->ReleaseAllFailedWriteRequests(req);
}
Expand Down Expand Up @@ -1491,7 +1491,7 @@ int Socket::StartWrite(WriteRequest* req, const WriteOptions& opt) {
int ret = ConnectIfNot(opt.abstime, req);
if (ret < 0) {
saved_errno = errno;
SetFailed(errno, "Fail to make %s connected: %m", description().c_str());
SetFailed(errno, "Fail to connect %s directly: %m", description().c_str());
goto FAIL_TO_WRITE;
} else if (ret == 1) {
// We are doing connection. Callback `KeepWriteIfConnected'
Expand Down
4 changes: 2 additions & 2 deletions test/brpc_socket_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ TEST_F(SocketTest, not_health_check_when_nref_hits_0) {
ASSERT_EQ(wait_id.value, data.id.value);
ASSERT_EQ(ECONNREFUSED, data.error_code);
ASSERT_TRUE(butil::StringPiece(data.error_text).starts_with(
"Fail to make SocketId="));
"Fail to connect SocketId="));
#else
ASSERT_EQ(-1, s->Write(&src));
ASSERT_EQ(ECONNREFUSED, errno);
Expand Down Expand Up @@ -577,7 +577,7 @@ TEST_F(SocketTest, health_check) {
ASSERT_EQ(wait_id.value, data.id.value);
ASSERT_EQ(ECONNREFUSED, data.error_code);
ASSERT_TRUE(butil::StringPiece(data.error_text).starts_with(
"Fail to make SocketId="));
"Fail to connect SocketId="));
if (use_my_message) {
ASSERT_TRUE(appended_msg);
}
Expand Down

0 comments on commit 3a2dee2

Please sign in to comment.