[Python-checkins] CVS: python/dist/src/Lib asyncore.py,1.24,1.25

Jeremy Hylton jhylton@users.sourceforge.net
2001年10月29日 08:32:24 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv21008
Modified Files:
	asyncore.py 
Log Message:
Fix for SF bug 453099 -- select not defensive
And SF patch 473223 -- infinite getattr loop
Wrap select() and poll() calls with try/except for EINTR. If EINTR is
raised, treat as a response where no fd is ready.
In dispatcher constructor, make sure self.socket is always
initialized.
Index: asyncore.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/asyncore.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** asyncore.py	2001年10月18日 17:33:19	1.24
--- asyncore.py	2001年10月29日 16:32:19	1.25
***************
*** 54,58 ****
 import os
 from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
! ENOTCONN, ESHUTDOWN
 
 try:
--- 54,58 ----
 import os
 from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \
! ENOTCONN, ESHUTDOWN, EINTR
 
 try:
***************
*** 67,71 ****
 
 def poll (timeout=0.0, map=None):
- global DEBUG
 if map is None:
 map = socket_map
--- 67,70 ----
***************
*** 77,81 ****
 if obj.writable():
 w.append (fd)
! r,w,e = select.select (r,w,e, timeout)
 
 if DEBUG:
--- 76,84 ----
 if obj.writable():
 w.append (fd)
! try:
! r,w,e = select.select (r,w,e, timeout)
! except select.error, err:
! if err[0] != EINTR:
! raise
 
 if DEBUG:
***************
*** 159,163 ****
 if flags:
 pollster.register(fd, flags)
! r = pollster.poll (timeout)
 for fd, flags in r:
 try:
--- 162,171 ----
 if flags:
 pollster.register(fd, flags)
! try:
! r = pollster.poll (timeout)
! except select.error, err:
! if err[0] != EINTR:
! raise
! r = []
 for fd, flags in r:
 try:
***************
*** 206,209 ****
--- 214,219 ----
 self.connected = 1
 self.addr = sock.getpeername()
+ else:
+ self.socket = None
 
 def __repr__ (self):
***************
*** 242,246 ****
 
 def set_socket (self, sock, map=None):
! self.__dict__['socket'] = sock
 self._fileno = sock.fileno()
 self.add_channel (map)
--- 252,257 ----
 
 def set_socket (self, sock, map=None):
! self.socket = sock
! ## self.__dict__['socket'] = sock
 self._fileno = sock.fileno()
 self.add_channel (map)

AltStyle によって変換されたページ (->オリジナル) /