mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-13 10:52:56 +01:00
Merge pull request #3103 from sigiesec/win-warnings-as-errors
Warnings in Windows builds
This commit is contained in:
commit
d81a041f18
@ -315,6 +315,7 @@ endif ()
|
||||
|
||||
if (LIBZMQ_WERROR)
|
||||
zmq_check_cxx_flag_prepend ("-Werror")
|
||||
zmq_check_cxx_flag_prepend ("/WX")
|
||||
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
zmq_check_cxx_flag_prepend ("-errwarn=%all")
|
||||
endif()
|
||||
|
@ -93,7 +93,7 @@ before_build:
|
||||
- cmd: set LIBZMQ_BUILDDIR=C:\projects\build_libzmq
|
||||
- cmd: md "%LIBZMQ_BUILDDIR%"
|
||||
- cd "%LIBZMQ_BUILDDIR%"
|
||||
- cmd: cmake -D CMAKE_INCLUDE_PATH="%SODIUM_INCLUDE_DIR%" -D CMAKE_LIBRARY_PATH="%SODIUM_LIBRARY_DIR%" -D WITH_LIBSODIUM="%WITH_LIBSODIUM%" -D ENABLE_CURVE="%ENABLE_CURVE%" -D POLLER="%POLLER%" -D CMAKE_C_FLAGS_RELEASE="/MT" -D CMAKE_C_FLAGS_DEBUG="/MTd" -D WITH_LIBSODIUM="%WITH_LIBSODIUM%" -G "%CMAKE_GENERATOR%" "%APPVEYOR_BUILD_FOLDER%"
|
||||
- cmd: cmake -D CMAKE_INCLUDE_PATH="%SODIUM_INCLUDE_DIR%" -D CMAKE_LIBRARY_PATH="%SODIUM_LIBRARY_DIR%" -D WITH_LIBSODIUM="%WITH_LIBSODIUM%" -D ENABLE_CURVE="%ENABLE_CURVE%" -D POLLER="%POLLER%" -D CMAKE_C_FLAGS_RELEASE="/MT" -D CMAKE_C_FLAGS_DEBUG="/MTd" -D WITH_LIBSODIUM="%WITH_LIBSODIUM%" -D LIBZMQ_WERROR="ON" -G "%CMAKE_GENERATOR%" "%APPVEYOR_BUILD_FOLDER%"
|
||||
|
||||
build:
|
||||
parallel: true
|
||||
|
@ -33,7 +33,7 @@ bool zmq::ip_addr_t::is_multicast () const
|
||||
return IN_MULTICAST (ntohl (ipv4.sin_addr.s_addr));
|
||||
} else {
|
||||
// IPv6 Multicast: ff00::/8
|
||||
return IN6_IS_ADDR_MULTICAST (&ipv6.sin6_addr);
|
||||
return IN6_IS_ADDR_MULTICAST (&ipv6.sin6_addr) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,10 @@
|
||||
#include "config.hpp"
|
||||
#include "i_poll_events.hpp"
|
||||
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
typedef unsigned long nfds_t;
|
||||
#endif
|
||||
|
||||
zmq::poll_t::poll_t (const zmq::thread_ctx_t &ctx_) :
|
||||
worker_poller_base_t (ctx_),
|
||||
retired (false)
|
||||
@ -155,7 +159,8 @@ void zmq::poll_t::loop ()
|
||||
}
|
||||
|
||||
// Wait for events.
|
||||
int rc = poll (&pollset[0], pollset.size (), timeout ? timeout : -1);
|
||||
int rc = poll (&pollset[0], static_cast<nfds_t> (pollset.size ()),
|
||||
timeout ? timeout : -1);
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
wsa_assert (rc != SOCKET_ERROR);
|
||||
#else
|
||||
|
@ -30,6 +30,16 @@
|
||||
#ifndef __ZMQ_PRECOMPILED_HPP_INCLUDED__
|
||||
#define __ZMQ_PRECOMPILED_HPP_INCLUDED__
|
||||
|
||||
// On AIX platform, poll.h has to be included first to get consistent
|
||||
// definition of pollfd structure (AIX uses 'reqevents' and 'retnevents'
|
||||
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
||||
// names to AIX-specific names).
|
||||
// zmq.h must be included *after* poll.h for AIX to build properly.
|
||||
// precompiled.hpp includes include/zmq.h
|
||||
#if defined ZMQ_POLL_BASED_ON_POLL && defined ZMQ_HAVE_AIX
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#include "platform.hpp"
|
||||
|
||||
#define __STDC_LIMIT_MACROS
|
||||
|
@ -27,17 +27,8 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// On AIX platform, poll.h has to be included first to get consistent
|
||||
// definition of pollfd structure (AIX uses 'reqevents' and 'retnevents'
|
||||
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
||||
// names to AIX-specific names).
|
||||
// zmq.h must be included *after* poll.h for AIX to build properly.
|
||||
// precompiled.hpp includes include/zmq.h
|
||||
#if defined ZMQ_POLL_BASED_ON_POLL && defined ZMQ_HAVE_AIX
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#include "precompiled.hpp"
|
||||
|
||||
#include <stddef.h>
|
||||
#include "poller.hpp"
|
||||
#include "proxy.hpp"
|
||||
|
@ -27,16 +27,6 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// On AIX, poll.h has to be included before zmq.h to get consistent
|
||||
// definition of pollfd structure (AIX uses 'reqevents' and 'retnevents'
|
||||
// instead of 'events' and 'revents' and defines macros to map from POSIX-y
|
||||
// names to AIX-specific names).
|
||||
// zmq.h must be included *after* poll.h for AIX to build properly.
|
||||
// precompiled.hpp includes include/zmq.h
|
||||
#if defined ZMQ_POLL_BASED_ON_POLL && defined ZMQ_HAVE_AIX
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "poller.hpp"
|
||||
|
||||
|
@ -210,7 +210,7 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_,
|
||||
options.socket_id = sid_;
|
||||
options.ipv6 = (parent_->get (ZMQ_IPV6) != 0);
|
||||
options.linger.store (parent_->get (ZMQ_BLOCKY) ? -1 : 0);
|
||||
options.zero_copy = parent_->get (ZMQ_ZERO_COPY_RECV);
|
||||
options.zero_copy = parent_->get (ZMQ_ZERO_COPY_RECV) != 0;
|
||||
|
||||
if (thread_safe) {
|
||||
mailbox = new (std::nothrow) mailbox_safe_t (&sync);
|
||||
|
@ -31,6 +31,8 @@
|
||||
#include "socket_poller.hpp"
|
||||
#include "err.hpp"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
static bool is_thread_safe (zmq::socket_base_t &socket)
|
||||
{
|
||||
// do not use getsockopt here, since that would fail during context termination
|
||||
@ -575,7 +577,8 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *events_,
|
||||
else if (timeout_ < 0)
|
||||
timeout = -1;
|
||||
else
|
||||
timeout = end - now;
|
||||
timeout =
|
||||
static_cast<int> (std::min<uint64_t> (end - now, INT_MAX));
|
||||
|
||||
// Wait for events.
|
||||
while (true) {
|
||||
|
@ -110,7 +110,7 @@ void zmq::udp_engine_t::plug (io_thread_t *io_thread_, session_base_t *session_)
|
||||
io_object_t::plug (io_thread_);
|
||||
handle = add_fd (fd);
|
||||
|
||||
const struct udp_address_t *udp_addr = address->resolved.udp_addr;
|
||||
const udp_address_t *const udp_addr = address->resolved.udp_addr;
|
||||
|
||||
// Bind the socket to a device if applicable
|
||||
if (!options.bound_device.empty ())
|
||||
|
@ -867,7 +867,8 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
||||
else if (timeout_ < 0)
|
||||
timeout = -1;
|
||||
else
|
||||
timeout = end - now;
|
||||
timeout =
|
||||
static_cast<int> (std::min<uint64_t> (end - now, INT_MAX));
|
||||
|
||||
// Wait for events.
|
||||
{
|
||||
|
@ -43,30 +43,6 @@ void tearDown ()
|
||||
teardown_test_context ();
|
||||
}
|
||||
|
||||
// duplicated from fd.hpp
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
#define close closesocket
|
||||
#if defined _MSC_VER && _MSC_VER <= 1400
|
||||
typedef UINT_PTR fd_t;
|
||||
enum
|
||||
{
|
||||
retired_fd = (fd_t) (~0)
|
||||
};
|
||||
#else
|
||||
typedef SOCKET fd_t;
|
||||
enum
|
||||
{
|
||||
retired_fd = (fd_t) INVALID_SOCKET
|
||||
};
|
||||
#endif
|
||||
#else
|
||||
typedef int fd_t;
|
||||
enum
|
||||
{
|
||||
retired_fd = -1
|
||||
};
|
||||
#endif
|
||||
|
||||
fd_t get_fd (void *socket)
|
||||
{
|
||||
fd_t fd;
|
||||
|
@ -241,9 +241,9 @@ void test_curve_security_with_plain_client_credentials ()
|
||||
expect_zmtp_mechanism_mismatch (client, my_endpoint, server, server_mon);
|
||||
}
|
||||
|
||||
int connect_vanilla_socket (char *my_endpoint)
|
||||
fd_t connect_vanilla_socket (char *my_endpoint)
|
||||
{
|
||||
int s;
|
||||
fd_t s;
|
||||
struct sockaddr_in ip4addr;
|
||||
|
||||
unsigned short int port;
|
||||
@ -267,7 +267,7 @@ int connect_vanilla_socket (char *my_endpoint)
|
||||
void test_curve_security_unauthenticated_message ()
|
||||
{
|
||||
// Unauthenticated messages from a vanilla socket shouldn't be received
|
||||
int s = connect_vanilla_socket (my_endpoint);
|
||||
fd_t s = connect_vanilla_socket (my_endpoint);
|
||||
// send anonymous ZMTP/1.0 greeting
|
||||
send (s, "\x01\x00", 2, 0);
|
||||
// send sneaky message that shouldn't be received
|
||||
@ -279,7 +279,7 @@ void test_curve_security_unauthenticated_message ()
|
||||
close (s);
|
||||
}
|
||||
|
||||
void send_all (int fd, const char *data, size_t size)
|
||||
void send_all (fd_t fd, const char *data, socket_size_t size)
|
||||
{
|
||||
while (size > 0) {
|
||||
int res = send (fd, data, size, 0);
|
||||
@ -289,12 +289,12 @@ void send_all (int fd, const char *data, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
template <size_t N> void send (int fd, const char (&data)[N])
|
||||
template <size_t N> void send (fd_t fd, const char (&data)[N])
|
||||
{
|
||||
send_all (fd, data, N - 1);
|
||||
}
|
||||
|
||||
void send_greeting (int s)
|
||||
void send_greeting (fd_t s)
|
||||
{
|
||||
send (s, "\xff\0\0\0\0\0\0\0\0\x7f"); // signature
|
||||
send (s, "\x03\x00"); // version 3.0
|
||||
@ -305,7 +305,7 @@ void send_greeting (int s)
|
||||
|
||||
void test_curve_security_invalid_hello_wrong_length ()
|
||||
{
|
||||
int s = connect_vanilla_socket (my_endpoint);
|
||||
fd_t s = connect_vanilla_socket (my_endpoint);
|
||||
|
||||
// send GREETING
|
||||
send_greeting (s);
|
||||
@ -360,7 +360,7 @@ uint64_t htonll (uint64_t value)
|
||||
}
|
||||
#endif
|
||||
|
||||
template <size_t N> void send_command (int s, char (&command)[N])
|
||||
template <size_t N> void send_command (fd_t s, char (&command)[N])
|
||||
{
|
||||
if (N < 256) {
|
||||
send (s, "\x04");
|
||||
@ -376,7 +376,7 @@ template <size_t N> void send_command (int s, char (&command)[N])
|
||||
|
||||
void test_curve_security_invalid_hello_command_name ()
|
||||
{
|
||||
int s = connect_vanilla_socket (my_endpoint);
|
||||
fd_t s = connect_vanilla_socket (my_endpoint);
|
||||
|
||||
send_greeting (s);
|
||||
|
||||
@ -401,7 +401,7 @@ void test_curve_security_invalid_hello_command_name ()
|
||||
|
||||
void test_curve_security_invalid_hello_version ()
|
||||
{
|
||||
int s = connect_vanilla_socket (my_endpoint);
|
||||
fd_t s = connect_vanilla_socket (my_endpoint);
|
||||
|
||||
send_greeting (s);
|
||||
|
||||
@ -424,7 +424,7 @@ void test_curve_security_invalid_hello_version ()
|
||||
close (s);
|
||||
}
|
||||
|
||||
void flush_read (int fd)
|
||||
void flush_read (fd_t fd)
|
||||
{
|
||||
int res;
|
||||
char buf[256];
|
||||
@ -434,9 +434,9 @@ void flush_read (int fd)
|
||||
TEST_ASSERT_NOT_EQUAL (-1, res);
|
||||
}
|
||||
|
||||
void recv_all (int fd, uint8_t *data, size_t len)
|
||||
void recv_all (fd_t fd, uint8_t *data, socket_size_t len)
|
||||
{
|
||||
size_t received = 0;
|
||||
socket_size_t received = 0;
|
||||
while (received < len) {
|
||||
int res = recv (fd, (char *) data, len, 0);
|
||||
TEST_ASSERT_GREATER_THAN_INT (0, res);
|
||||
@ -446,17 +446,17 @@ void recv_all (int fd, uint8_t *data, size_t len)
|
||||
}
|
||||
}
|
||||
|
||||
void recv_greeting (int fd)
|
||||
void recv_greeting (fd_t fd)
|
||||
{
|
||||
uint8_t greeting[64];
|
||||
recv_all (fd, greeting, 64);
|
||||
// TODO assert anything about the greeting received from the server?
|
||||
}
|
||||
|
||||
int connect_exchange_greeting_and_send_hello (char *my_endpoint,
|
||||
zmq::curve_client_tools_t &tools)
|
||||
fd_t connect_exchange_greeting_and_send_hello (char *my_endpoint,
|
||||
zmq::curve_client_tools_t &tools)
|
||||
{
|
||||
int s = connect_vanilla_socket (my_endpoint);
|
||||
fd_t s = connect_vanilla_socket (my_endpoint);
|
||||
|
||||
send_greeting (s);
|
||||
recv_greeting (s);
|
||||
@ -474,7 +474,7 @@ void test_curve_security_invalid_initiate_wrong_length ()
|
||||
{
|
||||
zmq::curve_client_tools_t tools = make_curve_client_tools ();
|
||||
|
||||
int s = connect_exchange_greeting_and_send_hello (my_endpoint, tools);
|
||||
fd_t s = connect_exchange_greeting_and_send_hello (my_endpoint, tools);
|
||||
|
||||
// receive but ignore WELCOME
|
||||
flush_read (s);
|
||||
@ -497,13 +497,13 @@ void test_curve_security_invalid_initiate_wrong_length ()
|
||||
close (s);
|
||||
}
|
||||
|
||||
int connect_exchange_greeting_and_hello_welcome (
|
||||
fd_t connect_exchange_greeting_and_hello_welcome (
|
||||
char *my_endpoint,
|
||||
void *server_mon,
|
||||
int timeout,
|
||||
zmq::curve_client_tools_t &tools)
|
||||
{
|
||||
int s = connect_exchange_greeting_and_send_hello (my_endpoint, tools);
|
||||
fd_t s = connect_exchange_greeting_and_send_hello (my_endpoint, tools);
|
||||
|
||||
// receive but ignore WELCOME
|
||||
uint8_t welcome[welcome_length + 2];
|
||||
@ -524,7 +524,7 @@ int connect_exchange_greeting_and_hello_welcome (
|
||||
void test_curve_security_invalid_initiate_command_name ()
|
||||
{
|
||||
zmq::curve_client_tools_t tools = make_curve_client_tools ();
|
||||
int s = connect_exchange_greeting_and_hello_welcome (
|
||||
fd_t s = connect_exchange_greeting_and_hello_welcome (
|
||||
my_endpoint, server_mon, timeout, tools);
|
||||
|
||||
char initiate[257];
|
||||
@ -546,7 +546,7 @@ void test_curve_security_invalid_initiate_command_name ()
|
||||
void test_curve_security_invalid_initiate_command_encrypted_cookie ()
|
||||
{
|
||||
zmq::curve_client_tools_t tools = make_curve_client_tools ();
|
||||
int s = connect_exchange_greeting_and_hello_welcome (
|
||||
fd_t s = connect_exchange_greeting_and_hello_welcome (
|
||||
my_endpoint, server_mon, timeout, tools);
|
||||
|
||||
char initiate[257];
|
||||
@ -568,7 +568,7 @@ void test_curve_security_invalid_initiate_command_encrypted_cookie ()
|
||||
void test_curve_security_invalid_initiate_command_encrypted_content ()
|
||||
{
|
||||
zmq::curve_client_tools_t tools = make_curve_client_tools ();
|
||||
int s = connect_exchange_greeting_and_hello_welcome (
|
||||
fd_t s = connect_exchange_greeting_and_hello_welcome (
|
||||
my_endpoint, server_mon, timeout, tools);
|
||||
|
||||
char initiate[257];
|
||||
|
@ -209,7 +209,7 @@ int main (void)
|
||||
assert (rc == 0);
|
||||
|
||||
struct sockaddr_in ip4addr;
|
||||
int s;
|
||||
fd_t s;
|
||||
|
||||
unsigned short int port;
|
||||
rc = sscanf (my_endpoint, "tcp://127.0.0.1:%hu", &port);
|
||||
|
@ -170,7 +170,7 @@ int main (void)
|
||||
|
||||
// Unauthenticated messages from a vanilla socket shouldn't be received
|
||||
struct sockaddr_in ip4addr;
|
||||
int s;
|
||||
fd_t s;
|
||||
|
||||
unsigned short int port;
|
||||
rc = sscanf (my_endpoint, "tcp://127.0.0.1:%hu", &port);
|
||||
|
@ -92,9 +92,9 @@ void test_pull_fair_queue_in (void *ctx)
|
||||
rc = zmq_getsockopt (pull, ZMQ_LAST_ENDPOINT, connect_address, &len);
|
||||
assert (rc == 0);
|
||||
|
||||
const size_t services = 5;
|
||||
const unsigned char services = 5;
|
||||
void *pushs[services];
|
||||
for (size_t peer = 0; peer < services; ++peer) {
|
||||
for (unsigned char peer = 0; peer < services; ++peer) {
|
||||
pushs[peer] = zmq_socket (ctx, ZMQ_PUSH);
|
||||
assert (pushs[peer]);
|
||||
|
||||
@ -109,7 +109,7 @@ void test_pull_fair_queue_in (void *ctx)
|
||||
int second_half = 0;
|
||||
|
||||
// Send 2N messages
|
||||
for (size_t peer = 0; peer < services; ++peer) {
|
||||
for (unsigned char peer = 0; peer < services; ++peer) {
|
||||
char *str = strdup ("A");
|
||||
|
||||
str[0] += peer;
|
||||
|
@ -47,9 +47,9 @@ void test_fair_queue_in (void *ctx)
|
||||
rc = zmq_getsockopt (receiver, ZMQ_LAST_ENDPOINT, connect_address, &len);
|
||||
assert (rc == 0);
|
||||
|
||||
const size_t services = 5;
|
||||
const unsigned char services = 5;
|
||||
void *senders[services];
|
||||
for (size_t peer = 0; peer < services; ++peer) {
|
||||
for (unsigned char peer = 0; peer < services; ++peer) {
|
||||
senders[peer] = zmq_socket (ctx, ZMQ_DEALER);
|
||||
assert (senders[peer]);
|
||||
|
||||
@ -82,7 +82,7 @@ void test_fair_queue_in (void *ctx)
|
||||
int sum = 0;
|
||||
|
||||
// send N requests
|
||||
for (size_t peer = 0; peer < services; ++peer) {
|
||||
for (unsigned char peer = 0; peer < services; ++peer) {
|
||||
s_send_seq (senders[peer], "M", SEQ_END);
|
||||
sum += 'A' + peer;
|
||||
}
|
||||
@ -90,7 +90,7 @@ void test_fair_queue_in (void *ctx)
|
||||
assert (sum == services * 'A' + services * (services - 1) / 2);
|
||||
|
||||
// handle N requests
|
||||
for (size_t peer = 0; peer < services; ++peer) {
|
||||
for (unsigned char peer = 0; peer < services; ++peer) {
|
||||
rc = zmq_msg_recv (&msg, receiver, 0);
|
||||
assert (rc == 2);
|
||||
const char *id = (const char *) zmq_msg_data (&msg);
|
||||
|
@ -198,14 +198,14 @@ int main (int, char **)
|
||||
|
||||
// Make sure payload matches what we expect.
|
||||
const char *const data = (const char *) zmq_msg_data (&data_frame);
|
||||
const int size = zmq_msg_size (&data_frame);
|
||||
const size_t size = zmq_msg_size (&data_frame);
|
||||
// 0-length frame is a disconnection notification. The server
|
||||
// should receive it as the last step in the dialogue.
|
||||
if (size == 0) {
|
||||
++step;
|
||||
assert (step == steps);
|
||||
} else {
|
||||
assert ((size_t) size == strlen (dialog[step].text));
|
||||
assert (size == strlen (dialog[step].text));
|
||||
int cmp = memcmp (dialog[step].text, data, size);
|
||||
assert (cmp == 0);
|
||||
|
||||
@ -259,8 +259,8 @@ int main (int, char **)
|
||||
|
||||
// Make sure payload matches what we expect.
|
||||
const char *const data = (const char *) zmq_msg_data (&data_frame);
|
||||
const int size = zmq_msg_size (&data_frame);
|
||||
assert ((size_t) size == strlen (dialog[step].text));
|
||||
const size_t size = zmq_msg_size (&data_frame);
|
||||
assert (size == strlen (dialog[step].text));
|
||||
int cmp = memcmp (dialog[step].text, data, size);
|
||||
assert (cmp == 0);
|
||||
|
||||
|
@ -82,7 +82,7 @@ int main (void)
|
||||
return -1;
|
||||
}
|
||||
// Check that we can create 1,000 sockets
|
||||
int handle[MAX_SOCKETS];
|
||||
fd_t handle[MAX_SOCKETS];
|
||||
int count;
|
||||
for (count = 0; count < MAX_SOCKETS; count++) {
|
||||
handle[count] = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
@ -88,6 +88,32 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// duplicated from fd.hpp
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
#define close closesocket
|
||||
typedef int socket_size_t;
|
||||
#if defined _MSC_VER && _MSC_VER <= 1400
|
||||
typedef UINT_PTR fd_t;
|
||||
enum
|
||||
{
|
||||
retired_fd = (fd_t) (~0)
|
||||
};
|
||||
#else
|
||||
typedef SOCKET fd_t;
|
||||
enum
|
||||
{
|
||||
retired_fd = (fd_t) INVALID_SOCKET
|
||||
};
|
||||
#endif
|
||||
#else
|
||||
typedef size_t socket_size_t;
|
||||
typedef int fd_t;
|
||||
enum
|
||||
{
|
||||
retired_fd = -1
|
||||
};
|
||||
#endif
|
||||
|
||||
#define LIBZMQ_UNUSED(object) (void) object
|
||||
|
||||
// Bounce a message from client to server and back
|
||||
@ -351,11 +377,11 @@ int is_ipv6_available (void)
|
||||
test_addr.sin6_family = AF_INET6;
|
||||
inet_pton (AF_INET6, "::1", &(test_addr.sin6_addr));
|
||||
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
SOCKET fd = socket (AF_INET6, SOCK_STREAM, IPPROTO_IP);
|
||||
if (fd == INVALID_SOCKET)
|
||||
fd_t fd = socket (AF_INET6, SOCK_STREAM, IPPROTO_IP);
|
||||
if (fd == retired_fd)
|
||||
ipv6 = 0;
|
||||
else {
|
||||
#ifdef ZMQ_HAVE_WINDOWS
|
||||
setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, (const char *) &ipv6,
|
||||
sizeof (int));
|
||||
rc = setsockopt (fd, IPPROTO_IPV6, IPV6_V6ONLY, (const char *) &ipv6,
|
||||
@ -367,13 +393,7 @@ int is_ipv6_available (void)
|
||||
if (rc == SOCKET_ERROR)
|
||||
ipv6 = 0;
|
||||
}
|
||||
closesocket (fd);
|
||||
}
|
||||
#else
|
||||
int fd = socket (AF_INET6, SOCK_STREAM, IPPROTO_IP);
|
||||
if (fd == -1)
|
||||
ipv6 = 0;
|
||||
else {
|
||||
setsockopt (fd, SOL_SOCKET, SO_REUSEADDR, &ipv6, sizeof (int));
|
||||
rc = setsockopt (fd, IPPROTO_IPV6, IPV6_V6ONLY, &ipv6, sizeof (int));
|
||||
if (rc != 0)
|
||||
@ -383,9 +403,9 @@ int is_ipv6_available (void)
|
||||
if (rc != 0)
|
||||
ipv6 = 0;
|
||||
}
|
||||
#endif
|
||||
close (fd);
|
||||
}
|
||||
#endif
|
||||
|
||||
return ipv6;
|
||||
#endif // _WIN32_WINNT < 0x0600
|
||||
@ -442,13 +462,4 @@ int test_inet_pton (int af_, const char *src_, void *dst_)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ZMQ_HAVE_WINDOWS)
|
||||
|
||||
int close (int fd)
|
||||
{
|
||||
return closesocket (fd);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -561,7 +561,7 @@ void setup_context_and_server_side (
|
||||
rc = zmq_setsockopt (*zap_control, ZMQ_LINGER, &linger, sizeof (linger));
|
||||
assert (rc == 0);
|
||||
|
||||
if (zap_handler_) {
|
||||
if (zap_handler_ != NULL) {
|
||||
*zap_thread = zmq_threadstart (zap_handler_, *ctx);
|
||||
|
||||
char *buf = s_recv (*zap_control);
|
||||
|
@ -64,7 +64,7 @@ class test_ip_resolver_t : public zmq::ip_resolver_t
|
||||
assert (service_ == NULL);
|
||||
|
||||
bool ipv6 = (hints_->ai_family == AF_INET6);
|
||||
bool no_dns = hints_->ai_flags & AI_NUMERICHOST;
|
||||
bool no_dns = (hints_->ai_flags & AI_NUMERICHOST) != 0;
|
||||
const char *ip = NULL;
|
||||
|
||||
if (!no_dns) {
|
||||
@ -156,9 +156,8 @@ static void test_resolve (zmq::ip_resolver_options_t opts_,
|
||||
TEST_ASSERT_EQUAL (0, rc);
|
||||
}
|
||||
|
||||
validate_address (family, &addr, expected_addr_,
|
||||
expected_port_, expected_zone_,
|
||||
expected_addr_v4_failover_);
|
||||
validate_address (family, &addr, expected_addr_, expected_port_,
|
||||
expected_zone_, expected_addr_v4_failover_);
|
||||
}
|
||||
|
||||
// Helper macro to define the v4/v6 function pairs
|
||||
@ -167,7 +166,7 @@ static void test_resolve (zmq::ip_resolver_options_t opts_,
|
||||
\
|
||||
static void _test##_ipv6 () { _test (true); }
|
||||
|
||||
static void test_bind_any (int ipv6_)
|
||||
static void test_bind_any (bool ipv6_)
|
||||
{
|
||||
zmq::ip_resolver_options_t resolver_opts;
|
||||
|
||||
@ -178,7 +177,7 @@ static void test_bind_any (int ipv6_)
|
||||
}
|
||||
MAKE_TEST_V4V6 (test_bind_any)
|
||||
|
||||
static void test_bind_any_port0 (int ipv6_)
|
||||
static void test_bind_any_port0 (bool ipv6_)
|
||||
{
|
||||
zmq::ip_resolver_options_t resolver_opts;
|
||||
|
||||
@ -190,7 +189,7 @@ static void test_bind_any_port0 (int ipv6_)
|
||||
}
|
||||
MAKE_TEST_V4V6 (test_bind_any_port0)
|
||||
|
||||
static void test_nobind_any (int ipv6_)
|
||||
static void test_nobind_any (bool ipv6_)
|
||||
{
|
||||
zmq::ip_resolver_options_t resolver_opts;
|
||||
|
||||
@ -202,7 +201,7 @@ static void test_nobind_any (int ipv6_)
|
||||
}
|
||||
MAKE_TEST_V4V6 (test_nobind_any)
|
||||
|
||||
static void test_nobind_any_port (int ipv6_)
|
||||
static void test_nobind_any_port (bool ipv6_)
|
||||
{
|
||||
zmq::ip_resolver_options_t resolver_opts;
|
||||
|
||||
@ -214,7 +213,7 @@ static void test_nobind_any_port (int ipv6_)
|
||||
}
|
||||
MAKE_TEST_V4V6 (test_nobind_any_port)
|
||||
|
||||
static void test_nobind_addr_anyport (int ipv6_)
|
||||
static void test_nobind_addr_anyport (bool ipv6_)
|
||||
{
|
||||
zmq::ip_resolver_options_t resolver_opts;
|
||||
|
||||
@ -225,7 +224,7 @@ static void test_nobind_addr_anyport (int ipv6_)
|
||||
}
|
||||
MAKE_TEST_V4V6 (test_nobind_addr_anyport)
|
||||
|
||||
static void test_nobind_addr_port0 (int ipv6_)
|
||||
static void test_nobind_addr_port0 (bool ipv6_)
|
||||
{
|
||||
zmq::ip_resolver_options_t resolver_opts;
|
||||
|
||||
@ -746,7 +745,7 @@ void test_dns_brackets_port_bad ()
|
||||
test_resolve (resolver_opts, "[ip.zeromq.org:22]", NULL);
|
||||
}
|
||||
|
||||
void test_dns_deny (int ipv6_)
|
||||
void test_dns_deny (bool ipv6_)
|
||||
{
|
||||
zmq::ip_resolver_options_t resolver_opts;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user