Skip to content
Snippets Groups Projects
Commit 82e3539d authored by chrysn's avatar chrysn
Browse files

Connection: Clean up in __destroy__

Cleaning up in __del__ (or any __del__, really) triggered pypy's checks
for valid C API use.

Closes: https://github.com/mclab-hbrs/DTLSSocket/issues/12
parent da236f15
No related branches found
No related tags found
No related merge requests found
...@@ -156,18 +156,20 @@ cdef class Connection(Session): ...@@ -156,18 +156,20 @@ cdef class Connection(Session):
def __init__(self, DTLS dtls, Session s): def __init__(self, DTLS dtls, Session s):
super().__init__(addr = s.addr, port = s.port, flowinfo=s.flowinfo, scope_id=s.scope_id) super().__init__(addr = s.addr, port = s.port, flowinfo=s.flowinfo, scope_id=s.scope_id)
self.d = dtls self.d = dtls
def __del__(self): def __dealloc__(self):
self.d.close(self) peer = tdtls.dtls_get_peer(self.d.ctx, &self.session)
self.d.resetPeer(self) if peer:
tdtls.dtls_reset_peer(self.d.ctx, peer)
cdef class MCConnection(Session): cdef class MCConnection(Session):
cdef DTLS d cdef DTLS d
def __init__(self, DTLS dtls, Session s): def __init__(self, DTLS dtls, Session s):
super().__init__(addr = s.addr, port = s.port, flowinfo=s.flowinfo, scope_id=s.scope_id) super().__init__(addr = s.addr, port = s.port, flowinfo=s.flowinfo, scope_id=s.scope_id)
self.d = dtls self.d = dtls
def __del__(self): def __dealloc__(self):
self.d.joinLeaveGroupe(self.addr, self.d._sock, join=False) peer = tdtls.dtls_get_peer(self.d.ctx, &self.session)
self.d.resetPeer(self) if peer:
tdtls.dtls_reset_peer(self.d.ctx, peer)
cdef class DTLS: cdef class DTLS:
cdef dtls_context_t *ctx cdef dtls_context_t *ctx
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment