Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Commit

Permalink
only delete subsocket when created by same object
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm committed Nov 4, 2019
1 parent 34df735 commit 21a3536
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion messaging/messaging_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,17 @@ cdef class Context:

cdef class Poller:
cdef cppPoller * poller
cdef list sub_sockets

def __cinit__(self):
self.sub_sockets = []
self.poller = cppPoller.create()

def __dealloc__(self):
del self.poller

def registerSocket(self, SubSocket socket):
self.sub_sockets.append(socket)
self.poller.registerSocket(socket.socket)

def poll(self, timeout):
Expand All @@ -46,15 +49,21 @@ cdef class Poller:

cdef class SubSocket:
cdef cppSubSocket * socket
cdef bool is_owner

def __cinit__(self):
self.socket = cppSubSocket.create()
self.is_owner = True

def __dealloc__(self):
if self.is_owner:
del self.socket

cdef setPtr(self, cppSubSocket * ptr):
del self.socket
if self.is_owner:
del self.socket

self.is_owner = False
self.socket = ptr

def connect(self, Context context, string endpoint, bool conflate=False):
Expand Down

0 comments on commit 21a3536

Please sign in to comment.