Skip to content

Commit

Permalink
Merge branch 'zeromq:master' into enable_emplace_feature_for_timers
Browse files Browse the repository at this point in the history
  • Loading branch information
githejie authored Aug 23, 2024
2 parents 87e17b1 + 5f408ba commit 1cdbf39
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
POLLER: poll
- os: ubuntu-latest
BUILD_TYPE: android
NDK_VERSION: android-ndk-r25
DRAFT: disabled
- os: ubuntu-latest
BUILD_TYPE: coverage
Expand Down Expand Up @@ -148,6 +149,8 @@ jobs:
USE_NSS: ${{ matrix.USE_NSS }}
VMCI: ${{ matrix.VMCI }}
POLLER: ${{ matrix.POLLER }}
NDK_VERSION: ${{ matrix.NDK_VERSION }}
ANDROID_NDK_ROOT: /tmp/${{ matrix.NDK_VERSION }}
steps:
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,18 @@ if(ZMQ_HAVE_WINDOWS)
# Cannot use check_library_exists because the symbol is always declared as char(*)(void)
set(CMAKE_REQUIRED_LIBRARIES "ws2_32.lib")
check_cxx_symbol_exists(WSAStartup "winsock2.h" HAVE_WS2_32)
if(HAVE_WS2_32)
set(pkg_config_libs_private "${pkg_config_libs_private} -lws2_32")
endif()

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

set(CMAKE_REQUIRED_LIBRARIES "iphlpapi.lib")
check_cxx_symbol_exists(GetAdaptersAddresses "winsock2.h;iphlpapi.h" HAVE_IPHLAPI)
if(HAVE_IPHLAPI)
set(pkg_config_libs_private "${pkg_config_libs_private} -liphlpapi")
endif()
check_cxx_symbol_exists(if_nametoindex "iphlpapi.h" HAVE_IF_NAMETOINDEX)

set(CMAKE_REQUIRED_LIBRARIES "")
Expand Down
4 changes: 4 additions & 0 deletions src/clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ uint64_t zmq::clock_t::rdtsc ()
((13 & 15) << 3) | // crm
((0 & 7) << 0)); // op2
return _ReadStatusReg (pmccntr_el0);
#elif (defined(_WIN32) && defined(__GNUC__) && defined(__aarch64__))
uint64_t val;
__asm__ volatile("mrs %0, pmccntr_el0" : "=r"(val));
return val;
#elif (defined __GNUC__ && (defined __i386__ || defined __x86_64__))
uint32_t low, high;
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
Expand Down
3 changes: 2 additions & 1 deletion src/socket_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_,
_monitor_events (0),
_thread_safe (thread_safe_),
_reaper_signaler (NULL),
_monitor_sync ()
_monitor_sync (),
_disconnected (false)
{
options.socket_id = sid_;
options.ipv6 = (parent_->get (ZMQ_IPV6) != 0);
Expand Down
43 changes: 43 additions & 0 deletions tests/test_reconnect_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,46 @@ void reconnect_stop_on_handshake_failed ()
}
#endif

#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_HAVE_IPC)
// test stopping reconnect after disconnect
void reconnect_stop_after_disconnect ()
{
// Setup sub socket
void *sub = test_context_socket (ZMQ_SUB);
// Monitor all events on sub
TEST_ASSERT_SUCCESS_ERRNO (
zmq_socket_monitor (sub, "inproc://monitor-sub", ZMQ_EVENT_ALL));
// Create socket for collecting monitor events
void *sub_mon = test_context_socket (ZMQ_PAIR);
// Connect so they'll get events
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sub_mon, "inproc://monitor-sub"));
// Set option to stop reconnecting after disconnect
int stopReconnectAfterDisconnect = ZMQ_RECONNECT_STOP_AFTER_DISCONNECT;
TEST_ASSERT_SUCCESS_ERRNO (
zmq_setsockopt (sub, ZMQ_RECONNECT_STOP, &stopReconnectAfterDisconnect,
sizeof (stopReconnectAfterDisconnect)));

// Connect to a dummy that cannot be connected
TEST_ASSERT_SUCCESS_ERRNO (zmq_connect (sub, "ipc://@dummy"));

// Confirm that connect failed and reconnect
expect_monitor_event (sub_mon, ZMQ_EVENT_CLOSED);
expect_monitor_event (sub_mon, ZMQ_EVENT_CONNECT_RETRIED);

// Disconnect the sub socket
TEST_ASSERT_SUCCESS_ERRNO (zmq_disconnect (sub, "ipc://@dummy"));

// Confirm that connect failed and will not reconnect
expect_monitor_event (sub_mon, ZMQ_EVENT_CLOSED);

// Close sub
test_context_socket_close_zero_linger (sub);

// Close monitor
test_context_socket_close_zero_linger (sub_mon);
}
#endif

void setUp ()
{
setup_test_context ();
Expand All @@ -267,6 +307,9 @@ int main (void)
#ifdef ZMQ_BUILD_DRAFT_API
RUN_TEST (reconnect_stop_on_refused);
RUN_TEST (reconnect_stop_on_handshake_failed);
#endif
#if defined(ZMQ_BUILD_DRAFT_API) && defined(ZMQ_HAVE_IPC)
RUN_TEST (reconnect_stop_after_disconnect);
#endif
return UNITY_END ();
}

0 comments on commit 1cdbf39

Please sign in to comment.