File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -142,4 +142,19 @@ TEST_CASE("monitor init abort", "[monitor]")
142142 monitor.abort ();
143143 thread.join ();
144144}
145+
146+
147+ TEST_CASE (" monitor from move assigned socket" , " [monitor]" )
148+ {
149+ zmq::context_t ctx;
150+ zmq::socket_t sock;
151+ sock = std::move ([&ctx] {
152+ zmq::socket_t sock (ctx, ZMQ_DEALER);
153+ return sock;
154+ }());
155+ zmq::monitor_t monitor1;
156+ monitor1.init (sock, " inproc://monitor-client" );
157+ // On failure, this test might hang indefinitely instead of immediately
158+ // failing
159+ }
145160#endif
Original file line number Diff line number Diff line change @@ -2103,6 +2103,7 @@ class socket_t : public detail::socket_base
21032103 {
21042104 close ();
21052105 std::swap (_handle, rhs._handle );
2106+ std::swap (ctxptr, rhs.ctxptr );
21062107 return *this ;
21072108 }
21082109#endif
@@ -2121,6 +2122,7 @@ class socket_t : public detail::socket_base
21212122 int rc = zmq_close (_handle);
21222123 ZMQ_ASSERT (rc == 0 );
21232124 _handle = ZMQ_NULLPTR;
2125+ ctxptr = ZMQ_NULLPTR;
21242126 }
21252127
21262128 void swap (socket_t &other) ZMQ_NOTHROW
@@ -2143,6 +2145,9 @@ class socket_t : public detail::socket_base
21432145 {
21442146 if (_handle == ZMQ_NULLPTR)
21452147 throw error_t ();
2148+ if (ctxptr == ZMQ_NULLPTR)
2149+ throw error_t ();
2150+
21462151 }
21472152};
21482153
You can’t perform that action at this time.
0 commit comments