Add sock paramater to Handler callbacks

As Handler objects can have multiple sockets, we need to know which one
was involved in the incoming event.
This commit is contained in:
Brian May
2015-11-24 12:19:31 +11:00
parent c1083e983f
commit 71d46d77bf
3 changed files with 19 additions and 19 deletions

View File

@ -260,7 +260,7 @@ class Handler:
for i in self.socks:
_add(r, i)
def callback(self):
def callback(self, sock):
log('--no callback defined-- %r\n' % self)
(r, w, x) = select.select(self.socks, [], [], 0)
for s in r:
@ -301,7 +301,7 @@ class Proxy(Handler):
elif not self.wrap2.shut_read:
_add(r, self.wrap2.rsock)
def callback(self):
def callback(self, sock):
self.wrap1.try_connect()
self.wrap2.try_connect()
self.wrap1.fill()
@ -467,7 +467,7 @@ class Mux(Handler):
if self.outbuf:
_add(w, self.wsock)
def callback(self):
def callback(self, sock):
(r, w, x) = select.select([self.rsock], [self.wsock], [], 0)
if self.rsock in r:
self.handle()
@ -572,7 +572,7 @@ def runonce(handlers, mux):
for h in handlers:
for s in h.socks:
if s in ready:
h.callback()
h.callback(s)
did[s] = 1
for s in ready:
if s not in did: