Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: When accepting a server, if the created file descriptor (FD) is 0, 1, or 2, avoid asserting to prevent a core dump #129

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions trpc/runtime/iomodel/reactor/default/tcp_acceptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ int TcpAcceptor::HandleReadEvent() {
NetworkAddress peer_addr;
int conn_fd = socket_.Accept(&peer_addr);
if (conn_fd >= 0) {
// When Accept returns standard input(0),standard output(1),and standard error(2), just only log
if (conn_fd < 3) {
TRPC_LOG_WARN("Accept return std fd,conn_fd:" << conn_fd);
}
AcceptConnectionFunction& accept_handler = GetAcceptHandleFunction();
if (accept_handler) {
AcceptConnectionInfo info;
Expand Down
4 changes: 4 additions & 0 deletions trpc/runtime/iomodel/reactor/fiber/fiber_acceptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ FiberConnection::EventAction FiberAcceptor::OnTcpReadable() {
NetworkAddress peer_addr;
int conn_fd = socket_.Accept(&peer_addr);
if (conn_fd >= 0) {
// When Accept returns standard input(0),standard output(1),and standard error(2), just only log
if (conn_fd < 3) {
TRPC_LOG_WARN("Accept return std fd,conn_fd:" << conn_fd);
}
if (accept_handler_) {
AcceptConnectionInfo info;

Expand Down
6 changes: 3 additions & 3 deletions trpc/runtime/iomodel/reactor/fiber/fiber_reactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ void TerminateAllReactor() {
}

Reactor* GetReactor(std::size_t scheduling_group, int fd) {
TRPC_CHECK(fd != 0 && fd != -1,
"You're likely passing in a fd got from calling `Get()` on an "
"invalid `Handle`.");
TRPC_CHECK(fd != -1,
"You're likely passing in a fd got from calling `Get()` on an "
"invalid `Handle`.");
if (fd == -2) {
fd = Random<int>();
}
Expand Down
Loading