Skip to content

Commit d3abe06

Browse files
committed
Problem: Move assigned objects still alive
Solution: Close context/socket if move assigned to
1 parent 5ee8261 commit d3abe06

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

zmq.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ class context_t
644644
context_t(context_t &&rhs) ZMQ_NOTHROW : ptr(rhs.ptr) { rhs.ptr = ZMQ_NULLPTR; }
645645
context_t &operator=(context_t &&rhs) ZMQ_NOTHROW
646646
{
647+
close();
647648
std::swap(ptr, rhs.ptr);
648649
return *this;
649650
}
@@ -1566,6 +1567,7 @@ class socket_t : public detail::socket_base
15661567
}
15671568
socket_t &operator=(socket_t &&rhs) ZMQ_NOTHROW
15681569
{
1570+
close();
15691571
std::swap(_handle, rhs._handle);
15701572
return *this;
15711573
}

0 commit comments

Comments
 (0)