Tied link teardown to resource cancellation
This commit is contained in:
parent
260f8bbaf1
commit
23ff873c63
@ -123,7 +123,6 @@ class Destination:
|
||||
def incomingLinkRequest(self, data, packet):
|
||||
link = RNS.Link.validateRequest(self, data, packet)
|
||||
if link != None:
|
||||
RNS.log(str(self)+" accepted link request", RNS.LOG_DEBUG)
|
||||
self.links.append(link)
|
||||
|
||||
def createKeys(self):
|
||||
|
@ -65,7 +65,9 @@ class Link:
|
||||
|
||||
if link.owner.callbacks.link_established != None:
|
||||
link.owner.callbacks.link_established(link)
|
||||
|
||||
RNS.log("Incoming link request "+str(link)+" accepted", RNS.LOG_VERBOSE)
|
||||
return link
|
||||
|
||||
except Exception as e:
|
||||
RNS.log("Validating link request failed", RNS.LOG_VERBOSE)
|
||||
@ -232,6 +234,11 @@ class Link:
|
||||
pass
|
||||
|
||||
def link_closed(self):
|
||||
for resource in self.incoming_resources:
|
||||
resource.cancel()
|
||||
for resource in self.outgoing_resources:
|
||||
resource.cancel()
|
||||
|
||||
self.prv = None
|
||||
self.pub = None
|
||||
self.pub_bytes = None
|
||||
|
@ -364,8 +364,9 @@ class Resource:
|
||||
def cancel(self):
|
||||
self.status = Resource.FAILED
|
||||
if self.initiator:
|
||||
cancel_packet = RNS.Packet(self.link, self.hash, context=RNS.Packet.RESOURCE_ICL)
|
||||
cancel_packet.send()
|
||||
if self.link.status == RNS.Link.ACTIVE:
|
||||
cancel_packet = RNS.Packet(self.link, self.hash, context=RNS.Packet.RESOURCE_ICL)
|
||||
cancel_packet.send()
|
||||
self.link.cancel_outgoing_resource(self)
|
||||
else:
|
||||
self.link.cancel_incoming_resource(self)
|
||||
|
Loading…
Reference in New Issue
Block a user