-- 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
diff --git a/lib/cpp/src/transport/TServerSocket.cpp b/lib/cpp/src/transport/TServerSocket.cpp
index e942a67..22346bd 100644
--- a/lib/cpp/src/transport/TServerSocket.cpp
+++ b/lib/cpp/src/transport/TServerSocket.cpp
@@ -169,6 +169,9 @@
 
   fd_set fds;
 
+  int maxEintrs = 5;
+  int numEintrs = 0;
+
   while (true) {
     FD_ZERO(&fds);
     FD_SET(serverSocket_, &fds);
@@ -178,6 +181,12 @@
     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 @@
   if (recvTimeout_ > 0) {
     client->setRecvTimeout(recvTimeout_);
   }
-
+  
   return client;
 }