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):
|
def incomingLinkRequest(self, data, packet):
|
||||||
link = RNS.Link.validateRequest(self, data, packet)
|
link = RNS.Link.validateRequest(self, data, packet)
|
||||||
if link != None:
|
if link != None:
|
||||||
RNS.log(str(self)+" accepted link request", RNS.LOG_DEBUG)
|
|
||||||
self.links.append(link)
|
self.links.append(link)
|
||||||
|
|
||||||
def createKeys(self):
|
def createKeys(self):
|
||||||
|
@ -65,7 +65,9 @@ class Link:
|
|||||||
|
|
||||||
if link.owner.callbacks.link_established != None:
|
if link.owner.callbacks.link_established != None:
|
||||||
link.owner.callbacks.link_established(link)
|
link.owner.callbacks.link_established(link)
|
||||||
|
|
||||||
RNS.log("Incoming link request "+str(link)+" accepted", RNS.LOG_VERBOSE)
|
RNS.log("Incoming link request "+str(link)+" accepted", RNS.LOG_VERBOSE)
|
||||||
|
return link
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Validating link request failed", RNS.LOG_VERBOSE)
|
RNS.log("Validating link request failed", RNS.LOG_VERBOSE)
|
||||||
@ -232,6 +234,11 @@ class Link:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def link_closed(self):
|
def link_closed(self):
|
||||||
|
for resource in self.incoming_resources:
|
||||||
|
resource.cancel()
|
||||||
|
for resource in self.outgoing_resources:
|
||||||
|
resource.cancel()
|
||||||
|
|
||||||
self.prv = None
|
self.prv = None
|
||||||
self.pub = None
|
self.pub = None
|
||||||
self.pub_bytes = None
|
self.pub_bytes = None
|
||||||
|
@ -364,6 +364,7 @@ class Resource:
|
|||||||
def cancel(self):
|
def cancel(self):
|
||||||
self.status = Resource.FAILED
|
self.status = Resource.FAILED
|
||||||
if self.initiator:
|
if self.initiator:
|
||||||
|
if self.link.status == RNS.Link.ACTIVE:
|
||||||
cancel_packet = RNS.Packet(self.link, self.hash, context=RNS.Packet.RESOURCE_ICL)
|
cancel_packet = RNS.Packet(self.link, self.hash, context=RNS.Packet.RESOURCE_ICL)
|
||||||
cancel_packet.send()
|
cancel_packet.send()
|
||||||
self.link.cancel_outgoing_resource(self)
|
self.link.cancel_outgoing_resource(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user