@@ -339,10 +339,10 @@ def callback(self, sock):
339
339
340
340
class Mux (Handler ):
341
341
342
- def __init__ (self , rsock , wsock ):
343
- Handler .__init__ (self , [rsock , wsock ])
344
- self .rsock = rsock
345
- self .wsock = wsock
342
+ def __init__ (self , rfile , wfile ):
343
+ Handler .__init__ (self , [rfile , wfile ])
344
+ self .rfile = rfile
345
+ self .wfile = wfile
346
346
self .new_channel = self .got_dns_req = self .got_routes = None
347
347
self .got_udp_open = self .got_udp_data = self .got_udp_close = None
348
348
self .got_host_req = self .got_host_list = None
@@ -439,19 +439,19 @@ def got_packet(self, channel, cmd, data):
439
439
callback (cmd , data )
440
440
441
441
def flush (self ):
442
- self .wsock . setblocking ( False )
442
+ os . set_blocking ( self .wfile . fileno (), False )
443
443
if self .outbuf and self .outbuf [0 ]:
444
- wrote = _nb_clean (os .write , self .wsock .fileno (), self .outbuf [0 ])
444
+ wrote = _nb_clean (os .write , self .wfile .fileno (), self .outbuf [0 ])
445
445
debug2 ('mux wrote: %r/%d\n ' % (wrote , len (self .outbuf [0 ])))
446
446
if wrote :
447
447
self .outbuf [0 ] = self .outbuf [0 ][wrote :]
448
448
while self .outbuf and not self .outbuf [0 ]:
449
449
self .outbuf [0 :1 ] = []
450
450
451
451
def fill (self ):
452
- self .rsock . setblocking ( False )
452
+ os . set_blocking ( self .rfile . fileno (), False )
453
453
try :
454
- read = _nb_clean (os .read , self .rsock .fileno (), LATENCY_BUFFER_SIZE )
454
+ read = _nb_clean (os .read , self .rfile .fileno (), LATENCY_BUFFER_SIZE )
455
455
except OSError :
456
456
_ , e = sys .exc_info ()[:2 ]
457
457
raise Fatal ('other end: %r' % e )
@@ -481,22 +481,22 @@ def handle(self):
481
481
break
482
482
483
483
def pre_select (self , r , w , x ):
484
- _add (r , self .rsock )
484
+ _add (r , self .rfile )
485
485
if self .outbuf :
486
- _add (w , self .wsock )
486
+ _add (w , self .wfile )
487
487
488
488
def callback (self , sock ):
489
- (r , w , _ ) = select .select ([self .rsock ], [self .wsock ], [], 0 )
490
- if self .rsock in r :
489
+ (r , w , _ ) = select .select ([self .rfile ], [self .wfile ], [], 0 )
490
+ if self .rfile in r :
491
491
self .handle ()
492
- if self .outbuf and self .wsock in w :
492
+ if self .outbuf and self .wfile in w :
493
493
self .flush ()
494
494
495
495
496
496
class MuxWrapper (SockWrapper ):
497
497
498
498
def __init__ (self , mux , channel ):
499
- SockWrapper .__init__ (self , mux .rsock , mux .wsock )
499
+ SockWrapper .__init__ (self , mux .rfile , mux .wfile )
500
500
self .mux = mux
501
501
self .channel = channel
502
502
self .mux .channels [channel ] = self .got_packet
0 commit comments