chenBright commented on code in PR #3525:
URL: https://github.com/apache/brpc/pull/3525#discussion_r3953856350
##########
test/brpc_socket_unittest.cpp:
##########
@@ -118,6 +118,17 @@ class CheckRecycle : public brpc::SocketUser {
}
};
+// Acceptor::Join() returns as soon as Acceptor::BeforeRecycle() cleared
+// _listened_fd, which Socket::BeforeRecycled() calls several statements before
+// it closes the fd, so the fd may still be open when Join() returns.
+void WaitForClosedFd(int fd) {
+ for (int i = 0; i < 100 && fcntl(fd, F_GETFD) != -1; ++i) {
+ bthread_usleep(10000);
+ }
+ ASSERT_EQ(-1, fcntl(fd, F_GETFD));
+ ASSERT_EQ(EBADF, errno);
Review Comment:
`fcntl` only returns `EINTR` for the blocking lock commands
(`F_SETLKW/F_OFD_SETLKW`);
`F_GETFD` just reads the `FD_CLOEXEC` bit from the fd table and can't be
interrupted, so
`EBADF` is its only realistic failure.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]