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

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


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

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


=== Zope/ZServer/medusa/asyncore.py 1.13 => 1.13.36.1 ===
 else:
     from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET
-    from errno import ENOTCONN, ESHUTDOWN, EINTR
+    from errno import ENOTCONN, ESHUTDOWN, EINTR, EAGAIN
 
 try:
     socket_map
@@ -472,7 +472,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 write (self, *args):
             return apply (os.write, (self.fd,)+args)