Skip to content

Commit

Permalink
protect against reentrant closing
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Aug 16, 2023
1 parent 6beb105 commit d538780
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions broker/src/tunneldigger_broker/tunnel.py
Expand Up @@ -79,6 +79,7 @@ def __init__(self, broker, address, endpoint, uuid, tunnel_id, remote_tunnel_id,
self.created_time = None
self.keepalive_seqno = 0
self.error_count = 0
self.closing = False

# Initialize PMTU values.
self.automatic_pmtu = pmtu_fixed == 0
Expand Down Expand Up @@ -260,6 +261,11 @@ def close(self, reason=protocol.ERROR_REASON_UNDEFINED):
:param reason: Reason code for the tunnel being closed
"""

if self.closing:
# While closing we send messages, and that can fail and we can recursively end up here again.
return
self.closing = True

logger.info("{}: Closing after {} seconds (reason=0x{:x})".format(self.name, int(time.time() - self.created_time), reason))

# Run pre-down hook.
Expand Down

0 comments on commit d538780

Please sign in to comment.