[Zope-Checkins] CVS: Zope/ZServer/medusa - asyncore.py:1.15.2.3

Brian Lloyd brian@zope.com
Mon, 21 Jan 2002 10:03:43 -0500


Update of /cvs-repository/Zope/ZServer/medusa
In directory cvs.zope.org:/tmp/cvs-serv17482

Modified Files:
      Tag: Zope-2_4-branch
	asyncore.py 
Log Message:
Backported fix for bug #157: asyncore hang on Linux 2.2.


=== Zope/ZServer/medusa/asyncore.py 1.15.2.2 => 1.15.2.3 ===
 import os
 from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
-     ENOTCONN, ESHUTDOWN, EINTR, EISCONN
+     ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EAGAIN
 
 try:
     socket_map
@@ -521,7 +521,15 @@
             self.fd = fd
 
         def recv (self, *args):
-            return apply (os.read, (self.fd,)+args)
+            # NOTE: this is a difference from the Python 2.2 library
+            # version of asyncore.py. This prevents a hanging condition
+            # on Linux 2.2 based systems.
+            while 1:
+                try:
+                    return apply (os.read, (self.fd,)+args)
+                except exceptions.OSError, why:
+                    if why[0] != EAGAIN:
+                        raise
 
         def send (self, *args):
             return apply (os.write, (self.fd,)+args)