From 9d48acd31902559a7cd970b9fe73a04bfa050431 Mon Sep 17 00:00:00 2001 From: Edouard Tisserant Date: Tue, 13 Sep 2016 18:56:54 +0200 Subject: [PATCH] Desynchronized accepting handshake from call to ShowHandshake, causing re-entrance in keysync's FSM driver --- test/multipEp.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/test/multipEp.py b/test/multipEp.py index 24617e2..3ac078e 100644 --- a/test/multipEp.py +++ b/test/multipEp.py @@ -13,6 +13,7 @@ own_addresses = [] indent = 0 i_name = "" handshakes_pending = [] +handshakes_to_accept = [] def create_account(address, name): global own_addresses @@ -73,9 +74,8 @@ def pEp_instance_run(iname, conn, msgs_folders, handshakes_seen, handshakes_vali printi(tw) if tw in handshakes_seen : handshakes_seen.remove(tw) - handshakes_validated.append(tw) - printi("ACCEPTED (already seen)") - self.deliverHandshakeResult(partner, 0) + handshakes_to_accept.append((tw,partner)) + printi("--> TO ACCEPT (already seen)") else: handshakes_pending.append((tw,partner)) handshakes_seen.append(tw) @@ -115,16 +115,16 @@ def pEp_instance_run(iname, conn, msgs_folders, handshakes_seen, handshakes_vali printi("---") printheader() - printheader("check validated handshakes") - for tple in handshakes_pending: - tw, partner = tple - if tw in handshakes_validated: - handshakes_validated.remove(tw) - handshakes_pending.remove(tple) - printi("ACCEPT pending handshake : "+ tw) - handler.deliverHandshakeResult(partner, 0) - - printheader() + if handshakes_pending: + printheader("check pending handshakes accepted on other device") + for tple in handshakes_pending: + tw, partner = tple + if tw in handshakes_validated: + handshakes_validated.remove(tw) + handshakes_pending.remove(tple) + printi("ACCEPT pending handshake : "+ tw) + handler.deliverHandshakeResult(partner, 0) + printheader() res = None if func is not None: @@ -136,6 +136,16 @@ def pEp_instance_run(iname, conn, msgs_folders, handshakes_seen, handshakes_vali printi("function " + func.__name__ + " returned :", res) printheader() + if handshakes_to_accept: + printheader("apply to-accept-because-already-seen handshakes") + for tple in handshakes_to_accept: + tw, partner = tple + printi("ACCEPT handshake : "+ tw) + handshakes_validated.append(tw) + handshakes_to_accept.remove(tple) + handler.deliverHandshakeResult(partner, 0) + printheader() + conn.send(res) def pEp_instance_main(iname, *args):