Skip to content

Commit

Permalink
avoid an possiblle infinite select loop
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbers committed Aug 11, 2012
1 parent c8e1744 commit bc1b348
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion quick_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def run(self):
try:
want_read = set([proxy]) | client_sockets | server_sockets
have_out_data = [s for s in data_to_send if data_to_send[s]]
want_write = set(have_out_data) | closed_but_data_left_sockets
want_write = set(have_out_data)

ready_read, ready_write = select(want_read, want_write,
[], 10)[:2]
Expand All @@ -120,13 +120,15 @@ def run(self):
except:
client_sockets.discard(s)
server_sockets.discard(s)
data_to_send[s] = b''

for s in want_write:
try:
select([], [s], [], 0)
except:
client_sockets.discard(s)
server_sockets.discard(s)
data_to_send[s] = b''
continue

# handling a new connect to the proxy
Expand Down

0 comments on commit bc1b348

Please sign in to comment.