Skip to content

Commit

Permalink
pyverbs: Raise exception right after create QP fails
Browse files Browse the repository at this point in the history
To avoid refcounting the QP when create_qp failed move the throw exception
to be right after create QP.

Signed-off-by: Kamal Heib <kamalheib1@gmail.com>
  • Loading branch information
Kamalheib committed Jan 16, 2020
1 parent 55654e7 commit 8b8a4e5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyverbs/qp.pyx
Expand Up @@ -891,6 +891,8 @@ cdef class QP(PyverbsCM):
# let's infer the type.
if issubclass(type(creator), Context):
self._create_qp_ex(creator, init_attr)
if self.qp == NULL:
raise PyverbsRDMAErrno('Failed to create QP')
ctx = <Context>creator
self.context = ctx
ctx.add_ref(self)
Expand All @@ -902,14 +904,15 @@ cdef class QP(PyverbsCM):
xrcd = <XRCD>init_attr.xrcd
xrcd.add_ref(self)
self.xrcd = xrcd

else:
self._create_qp(creator, init_attr)
if self.qp == NULL:
raise PyverbsRDMAErrno('Failed to create QP')
pd = <PD>creator
self.pd = pd
pd.add_ref(self)
self.context = None
if self.qp == NULL:
raise PyverbsRDMAErrno('Failed to create QP')

if qp_attr is not None:
funcs = {e.IBV_QPT_RC: self.to_init, e.IBV_QPT_UC: self.to_init,
Expand Down

0 comments on commit 8b8a4e5

Please sign in to comment.