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

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


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

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


=== Zope/ZServer/medusa/asyncore.py 1.16 => 1.16.12.1 ===
 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)