Skip to content

Commit 1cdbf39

Browse files
authored
Merge branch 'zeromq:master' into enable_emplace_feature_for_timers
2 parents 87e17b1 + 5f408ba commit 1cdbf39

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

.github/workflows/CI.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
POLLER: poll
3535
- os: ubuntu-latest
3636
BUILD_TYPE: android
37+
NDK_VERSION: android-ndk-r25
3738
DRAFT: disabled
3839
- os: ubuntu-latest
3940
BUILD_TYPE: coverage
@@ -148,6 +149,8 @@ jobs:
148149
USE_NSS: ${{ matrix.USE_NSS }}
149150
VMCI: ${{ matrix.VMCI }}
150151
POLLER: ${{ matrix.POLLER }}
152+
NDK_VERSION: ${{ matrix.NDK_VERSION }}
153+
ANDROID_NDK_ROOT: /tmp/${{ matrix.NDK_VERSION }}
151154
steps:
152155
- name: Add msbuild to PATH
153156
uses: microsoft/[email protected]

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,18 @@ if(ZMQ_HAVE_WINDOWS)
567567
# Cannot use check_library_exists because the symbol is always declared as char(*)(void)
568568
set(CMAKE_REQUIRED_LIBRARIES "ws2_32.lib")
569569
check_cxx_symbol_exists(WSAStartup "winsock2.h" HAVE_WS2_32)
570+
if(HAVE_WS2_32)
571+
set(pkg_config_libs_private "${pkg_config_libs_private} -lws2_32")
572+
endif()
570573

571574
set(CMAKE_REQUIRED_LIBRARIES "rpcrt4.lib")
572575
check_cxx_symbol_exists(UuidCreateSequential "rpc.h" HAVE_RPCRT4)
573576

574577
set(CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib")
575578
check_cxx_symbol_exists(GetAdaptersAddresses "winsock2.h;iphlpapi.h" HAVE_IPHLAPI)
579+
if(HAVE_IPHLAPI)
580+
set(pkg_config_libs_private "${pkg_config_libs_private} -liphlpapi")
581+
endif()
576582
check_cxx_symbol_exists(if_nametoindex "iphlpapi.h" HAVE_IF_NAMETOINDEX)
577583

578584
set(CMAKE_REQUIRED_LIBRARIES "")

src/clock.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ uint64_t zmq::clock_t::rdtsc ()
223223
((13 & 15) << 3) | // crm
224224
((0 & 7) << 0)); // op2
225225
return _ReadStatusReg (pmccntr_el0);
226+
#elif (defined(_WIN32) && defined(__GNUC__) && defined(__aarch64__))
227+
uint64_t val;
228+
__asm__ volatile("mrs %0, pmccntr_el0" : "=r"(val));
229+
return val;
226230
#elif (defined __GNUC__ && (defined __i386__ || defined __x86_64__))
227231
uint32_t low, high;
228232
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));

src/socket_base.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_,
228228
_monitor_events (0),
229229
_thread_safe (thread_safe_),
230230
_reaper_signaler (NULL),
231-
_monitor_sync ()
231+
_monitor_sync (),
232+
_disconnected (false)
232233
{
233234
options.socket_id = sid_;
234235
options.ipv6 = (parent_->get (ZMQ_IPV6) != 0);

tests/test_reconnect_options.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,46 @@ void reconnect_stop_on_handshake_failed ()
246246
}
247247
#endif
248248

249+
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_HAVE_IPC)
250+
// test stopping reconnect after disconnect
251+
void reconnect_stop_after_disconnect ()
252+
{
253+
// Setup sub socket
254+
void *sub = test_context_socket (ZMQ_SUB);
255+
// Monitor all events on sub
256+
TEST_ASSERT_SUCCESS_ERRNO (
257+
zmq_socket_monitor (sub, "inproc://monitor-sub", ZMQ_EVENT_ALL));
258+
// Create socket for collecting monitor events
259+
void *sub_mon = test_context_socket (ZMQ_PAIR);
260+
// Connect so they'll get events
261+
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sub_mon, "inproc://monitor-sub"));
262+
// Set option to stop reconnecting after disconnect
263+
int stopReconnectAfterDisconnect = ZMQ_RECONNECT_STOP_AFTER_DISCONNECT;
264+
TEST_ASSERT_SUCCESS_ERRNO (
265+
zmq_setsockopt (sub, ZMQ_RECONNECT_STOP, &stopReconnectAfterDisconnect,
266+
sizeof (stopReconnectAfterDisconnect)));
267+
268+
// Connect to a dummy that cannot be connected
269+
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sub, "ipc://@dummy"));
270+
271+
// Confirm that connect failed and reconnect
272+
expect_monitor_event (sub_mon, ZMQ_EVENT_CLOSED);
273+
expect_monitor_event (sub_mon, ZMQ_EVENT_CONNECT_RETRIED);
274+
275+
// Disconnect the sub socket
276+
TEST_ASSERT_SUCCESS_ERRNO (zmq_disconnect (sub, "ipc://@dummy"));
277+
278+
// Confirm that connect failed and will not reconnect
279+
expect_monitor_event (sub_mon, ZMQ_EVENT_CLOSED);
280+
281+
// Close sub
282+
test_context_socket_close_zero_linger (sub);
283+
284+
// Close monitor
285+
test_context_socket_close_zero_linger (sub_mon);
286+
}
287+
#endif
288+
249289
void setUp ()
250290
{
251291
setup_test_context ();
@@ -267,6 +307,9 @@ int main (void)
267307
#ifdef ZMQ_BUILD_DRAFT_API
268308
RUN_TEST (reconnect_stop_on_refused);
269309
RUN_TEST (reconnect_stop_on_handshake_failed);
310+
#endif
311+
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_HAVE_IPC)
312+
RUN_TEST (reconnect_stop_after_disconnect);
270313
#endif
271314
return UNITY_END ();
272315
}

0 commit comments

Comments
 (0)