Permalink
Browse files

Merge branch 'python23' - python 2.3 compatibility

* python23:
  Oops, missed another << operator to replace with _shl().
  socket.SHUT_RD and socket.SHUT_WR don't exist in python 2.3.
  compat/ssubprocess.py: some python versions don't have os.closerange().
  _nb_clean: don't catch EPIPE after all.
  Fix busy-waiting in two situations:
  Factor out common mainloop code between client and server.
  Implement our own left-shift operator to shut up python 2.3 warnings.
  Don't use set() since it's not in python 2.3.
  import and use subprocess.py from python 2.6.
  Remove list comprehensions for python 2.3 compatibility.
  • Loading branch information...
2 parents 518df41 + 5070f2f commit ae32fe2a59934c39a57b0e06a554033af9c553bb @apenwarr apenwarr committed Oct 2, 2010
Showing with 1,433 additions and 69 deletions.
  1. +5 −16 client.py
  2. 0 compat/__init__.py
  3. +1,305 −0 compat/ssubprocess.py
  4. +8 −7 firewall.py
  5. +7 −0 helpers.py
  6. +5 −4 hostwatch.py
  7. +13 −22 server.py
  8. +6 −3 ssh.py
  9. +84 −17 ssnet.py
View
@@ -1,8 +1,10 @@
-import struct, socket, select, subprocess, errno, re
+import struct, socket, select, errno, re
+import compat.ssubprocess as ssubprocess
import helpers, ssnet, ssh
from ssnet import SockWrapper, Handler, Proxy, Mux, MuxWrapper
from helpers import *
+
def original_dst(sock):
try:
SO_ORIGINAL_DST = 80
@@ -45,7 +47,7 @@ def setup():
e = None
for argv in argv_tries:
try:
- self.p = subprocess.Popen(argv, stdout=s1, preexec_fn=setup)
+ self.p = ssubprocess.Popen(argv, stdout=s1, preexec_fn=setup)
e = None
break
except OSError, e:
@@ -175,20 +177,7 @@ def onaccept():
if rv:
raise Fatal('server died with error code %d' % rv)
- r = set()
- w = set()
- x = set()
- handlers = filter(lambda s: s.ok, handlers)
- for s in handlers:
- s.pre_select(r,w,x)
- debug2('Waiting: %d[%d,%d,%d]...\n'
- % (len(handlers), len(r), len(w), len(x)))
- (r,w,x) = select.select(r,w,x)
- #log('r=%r w=%r x=%r\n' % (r,w,x))
- ready = set(r) | set(w) | set(x)
- for s in handlers:
- if s.socks & ready:
- s.callback()
+ ssnet.runonce(handlers, mux)
if use_server:
mux.callback()
mux.check_fullness()
View
No changes.
Oops, something went wrong.

0 comments on commit ae32fe2

Please sign in to comment.