mirror of
https://github.com/zeromq/cppzmq.git
synced 2024-12-12 10:33:52 +01:00
Merge pull request #432 from or17191/bugfix/socket-move-assignment-not-initializing-ctxptr
Bugfix: socket_t move assignment doesn't initialize ctxptr
This commit is contained in:
commit
7efc9b153f
@ -142,4 +142,19 @@ TEST_CASE("monitor init abort", "[monitor]")
|
||||
monitor.abort();
|
||||
thread.join();
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("monitor from move assigned socket", "[monitor]")
|
||||
{
|
||||
zmq::context_t ctx;
|
||||
zmq::socket_t sock;
|
||||
sock = std::move([&ctx] {
|
||||
zmq::socket_t sock(ctx, ZMQ_DEALER);
|
||||
return sock;
|
||||
}());
|
||||
zmq::monitor_t monitor1;
|
||||
monitor1.init(sock, "inproc://monitor-client");
|
||||
// On failure, this test might hang indefinitely instead of immediately
|
||||
// failing
|
||||
}
|
||||
#endif
|
||||
|
5
zmq.hpp
5
zmq.hpp
@ -2103,6 +2103,7 @@ class socket_t : public detail::socket_base
|
||||
{
|
||||
close();
|
||||
std::swap(_handle, rhs._handle);
|
||||
std::swap(ctxptr, rhs.ctxptr);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@ -2121,6 +2122,7 @@ class socket_t : public detail::socket_base
|
||||
int rc = zmq_close(_handle);
|
||||
ZMQ_ASSERT(rc == 0);
|
||||
_handle = ZMQ_NULLPTR;
|
||||
ctxptr = ZMQ_NULLPTR;
|
||||
}
|
||||
|
||||
void swap(socket_t &other) ZMQ_NOTHROW
|
||||
@ -2143,6 +2145,9 @@ class socket_t : public detail::socket_base
|
||||
{
|
||||
if (_handle == ZMQ_NULLPTR)
|
||||
throw error_t();
|
||||
if (ctxptr == ZMQ_NULLPTR)
|
||||
throw error_t();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user