Commit e47c381c authored by Andrew M. Kuchling's avatar Andrew M. Kuchling

[Bug #1011606] Only check file descriptors for exceptional conditions if the...

[Bug #1011606] Only check file descriptors for exceptional conditions if the fd is readable or writable
parent 3b2cdad4
...@@ -107,11 +107,14 @@ def poll(timeout=0.0, map=None): ...@@ -107,11 +107,14 @@ def poll(timeout=0.0, map=None):
if map: if map:
r = []; w = []; e = [] r = []; w = []; e = []
for fd, obj in map.items(): for fd, obj in map.items():
e.append(fd) is_r = obj.readable()
if obj.readable(): is_w = obj.writable()
if is_r:
r.append(fd) r.append(fd)
if obj.writable(): if is_w:
w.append(fd) w.append(fd)
if is_r or is_w:
e.append(fd)
if [] == r == w == e: if [] == r == w == e:
time.sleep(timeout) time.sleep(timeout)
else: else:
...@@ -151,12 +154,15 @@ def poll2(timeout=0.0, map=None): ...@@ -151,12 +154,15 @@ def poll2(timeout=0.0, map=None):
pollster = select.poll() pollster = select.poll()
if map: if map:
for fd, obj in map.items(): for fd, obj in map.items():
flags = select.POLLERR | select.POLLHUP | select.POLLNVAL flags = 0
if obj.readable(): if obj.readable():
flags |= select.POLLIN | select.POLLPRI flags |= select.POLLIN | select.POLLPRI
if obj.writable(): if obj.writable():
flags |= select.POLLOUT flags |= select.POLLOUT
if flags: if flags:
# Only check for exceptions if object was either readable
# or writable.
flags |= select.POLLERR | select.POLLHUP | select.POLLNVAL
pollster.register(fd, flags) pollster.register(fd, flags)
try: try:
r = pollster.poll(timeout) r = pollster.poll(timeout)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment