Assertion in dtor of context_t doesn't fail if close method has already been called

This commit is contained in:
Serge Medvedev 2016-09-19 10:05:32 +03:00
parent 92d2af6def
commit 8214a500d9

View File

@ -410,14 +410,17 @@ namespace zmq
inline ~context_t () ZMQ_NOTHROW inline ~context_t () ZMQ_NOTHROW
{ {
int rc = zmq_ctx_destroy (ptr); close();
ZMQ_ASSERT (rc == 0);
} }
inline void close() ZMQ_NOTHROW inline void close() ZMQ_NOTHROW
{ {
if (ptr == NULL)
return;
int rc = zmq_ctx_destroy (ptr); int rc = zmq_ctx_destroy (ptr);
ZMQ_ASSERT (rc == 0); ZMQ_ASSERT (rc == 0);
ptr = NULL;
} }
// Be careful with this, it's probably only useful for // Be careful with this, it's probably only useful for