mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 18:58:51 +00:00
-- handle EINTRS in accept()
Summary: - I love unix. Reviewed By: mcslee Test Plan: boz will test it git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665125 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
448849deed
commit
7859a579db
@ -169,6 +169,9 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {
|
||||
|
||||
fd_set fds;
|
||||
|
||||
int maxEintrs = 5;
|
||||
int numEintrs = 0;
|
||||
|
||||
while (true) {
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(serverSocket_, &fds);
|
||||
@ -178,6 +181,12 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {
|
||||
int ret = select(serverSocket_+1, &fds, NULL, NULL, NULL);
|
||||
|
||||
if (ret < 0) {
|
||||
// error cases
|
||||
if (error == EINTR && (numEintrs++ < maxEintrs)) {
|
||||
// EINTR needs to be handled manually and we can tolerate
|
||||
// a certain number
|
||||
continue;
|
||||
}
|
||||
perror("TServerSocket::acceptImpl() select -1");
|
||||
throw TTransportException(TTransportException::UNKNOWN);
|
||||
} else if (ret > 0) {
|
||||
@ -228,7 +237,7 @@ shared_ptr<TTransport> TServerSocket::acceptImpl() {
|
||||
if (recvTimeout_ > 0) {
|
||||
client->setRecvTimeout(recvTimeout_);
|
||||
}
|
||||
|
||||
|
||||
return client;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user