very temporary socket tracking dbg

This commit is contained in:
ed 2019-06-25 21:24:52 +00:00
parent 9fcd4823b5
commit 9ef3945abf
5 changed files with 11 additions and 3 deletions

View file

@ -68,6 +68,7 @@ class MpWorker(object):
if PY2: if PY2:
sck = pickle.loads(sck) # nosec sck = pickle.loads(sck) # nosec
self.log(str(d[2]), "-" * 4 + "C-qpop")
self.httpsrv.accept(sck, d[2]) self.httpsrv.accept(sck, d[2])
with self.mutex: with self.mutex:

View file

@ -27,6 +27,7 @@ class BrokerThr(object):
def put(self, retq, act, *args): def put(self, retq, act, *args):
if act == "httpconn": if act == "httpconn":
sck, addr = args sck, addr = args
self.log(str(addr), "-" * 4 + "C-qpop")
self.httpsrv.accept(sck, addr) self.httpsrv.accept(sck, addr)
else: else:

View file

@ -59,11 +59,11 @@ class HttpConn(object):
self.s = ssl.wrap_socket( self.s = ssl.wrap_socket(
self.s, server_side=True, certfile=self.cert_path self.s, server_side=True, certfile=self.cert_path
) )
except OSError as ex: except Exception as ex:
if "ALERT_BAD_CERTIFICATE" in ex.strerror: if "ALERT_BAD_CERTIFICATE" in str(ex):
self.log("client rejected our certificate (nice)") self.log("client rejected our certificate (nice)")
else: else:
raise self.log("\033[35mhandshake\033[0m " + str(ex))
return return

View file

@ -37,6 +37,7 @@ class HttpSrv(object):
def accept(self, sck, addr): def accept(self, sck, addr):
"""takes an incoming tcp connection and creates a thread to handle it""" """takes an incoming tcp connection and creates a thread to handle it"""
self.log(str(addr), "-" * 5 + "C-cthr")
thr = threading.Thread(target=self.thr_client, args=(sck, addr, self.log)) thr = threading.Thread(target=self.thr_client, args=(sck, addr, self.log))
thr.daemon = True thr.daemon = True
thr.start() thr.start()
@ -62,9 +63,11 @@ class HttpSrv(object):
thr.start() thr.start()
try: try:
self.log(str(addr), "-" * 6 + "C-crun")
cli.run() cli.run()
finally: finally:
self.log(str(addr), "-" * 7 + "C-done")
sck.close() sck.close()
with self.mutex: with self.mutex:
del self.clients[cli] del self.clients[cli]

View file

@ -59,11 +59,14 @@ class TcpSrv(object):
self.log("tcpsrv", "listening @ {0}:{1}".format(self.args.i, self.args.p)) self.log("tcpsrv", "listening @ {0}:{1}".format(self.args.i, self.args.p))
while True: while True:
self.log("tcpsrv", "-" * 1 + "C-ncli")
if self.num_clients.v >= self.args.nc: if self.num_clients.v >= self.args.nc:
time.sleep(0.1) time.sleep(0.1)
continue continue
self.log("tcpsrv", "-" * 2 + "C-acc1")
sck, addr = self.srv.accept() sck, addr = self.srv.accept()
self.log(str(addr), "-" * 3 + "C-acc2")
self.num_clients.add() self.num_clients.add()
self.hub.broker.put(None, "httpconn", sck, addr) self.hub.broker.put(None, "httpconn", sck, addr)