THRIFT-2466: Improper error handling for SSL/TLS connections that don't complete a handshake
Client: Python
Patch: Benoit Sigoure
diff --git a/lib/py/src/server/TProcessPoolServer.py b/lib/py/src/server/TProcessPoolServer.py
index 7a695a8..7369466 100644
--- a/lib/py/src/server/TProcessPoolServer.py
+++ b/lib/py/src/server/TProcessPoolServer.py
@@ -56,6 +56,8 @@
         while self.isRunning.value:
             try:
                 client = self.serverTransport.accept()
+                if not client:
+                  continue
                 self.serveClient(client)
             except (KeyboardInterrupt, SystemExit):
                 return 0
diff --git a/lib/py/src/server/TServer.py b/lib/py/src/server/TServer.py
index 2f24842..976a8f3 100644
--- a/lib/py/src/server/TServer.py
+++ b/lib/py/src/server/TServer.py
@@ -75,6 +75,8 @@
     self.serverTransport.listen()
     while True:
       client = self.serverTransport.accept()
+      if not client:
+        continue
       itrans = self.inputTransportFactory.getTransport(client)
       otrans = self.outputTransportFactory.getTransport(client)
       iprot = self.inputProtocolFactory.getProtocol(itrans)
@@ -103,6 +105,8 @@
     while True:
       try:
         client = self.serverTransport.accept()
+        if not client:
+          continue
         t = threading.Thread(target=self.handle, args=(client,))
         t.setDaemon(self.daemon)
         t.start()
@@ -182,6 +186,8 @@
     while True:
       try:
         client = self.serverTransport.accept()
+        if not client:
+          continue
         self.clients.put(client)
       except Exception, x:
         logging.exception(x)
@@ -214,6 +220,8 @@
     self.serverTransport.listen()
     while True:
       client = self.serverTransport.accept()
+      if not client:
+        continue
       try:
         pid = os.fork()