File tree 2 files changed +20
-0
lines changed
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]")
142
142
monitor.abort ();
143
143
thread.join ();
144
144
}
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
+ }
145
160
#endif
Original file line number Diff line number Diff line change @@ -2103,6 +2103,7 @@ class socket_t : public detail::socket_base
2103
2103
{
2104
2104
close ();
2105
2105
std::swap (_handle, rhs._handle );
2106
+ std::swap (ctxptr, rhs.ctxptr );
2106
2107
return *this ;
2107
2108
}
2108
2109
#endif
@@ -2121,6 +2122,7 @@ class socket_t : public detail::socket_base
2121
2122
int rc = zmq_close (_handle);
2122
2123
ZMQ_ASSERT (rc == 0 );
2123
2124
_handle = ZMQ_NULLPTR;
2125
+ ctxptr = ZMQ_NULLPTR;
2124
2126
}
2125
2127
2126
2128
void swap (socket_t &other) ZMQ_NOTHROW
@@ -2143,6 +2145,9 @@ class socket_t : public detail::socket_base
2143
2145
{
2144
2146
if (_handle == ZMQ_NULLPTR)
2145
2147
throw error_t ();
2148
+ if (ctxptr == ZMQ_NULLPTR)
2149
+ throw error_t ();
2150
+
2146
2151
}
2147
2152
};
2148
2153
You can’t perform that action at this time.
0 commit comments