From e895607ca7a97378f7ccc5ab050fc54fd54a80ad Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 14 Jun 2011 09:58:18 +0200 Subject: [PATCH 1/3] ENETUNREACH is a valid error from connect This patch fixed the JIRA issue 223 Signed-off-by: Martin Sustrik --- src/tcp_connecter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tcp_connecter.cpp b/src/tcp_connecter.cpp index 94891b52..9515f553 100644 --- a/src/tcp_connecter.cpp +++ b/src/tcp_connecter.cpp @@ -295,7 +295,8 @@ zmq::fd_t zmq::tcp_connecter_t::connect () // Networking problems are OK. No need to assert. errno = err; errno_assert (errno == ECONNREFUSED || errno == ECONNRESET || - errno == ETIMEDOUT || errno == EHOSTUNREACH); + errno == ETIMEDOUT || errno == EHOSTUNREACH || + errno == ENETUNREACH); return retired_fd; } From dc66053530e798dbcdb236cc2040031980cc09c7 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sat, 18 Jun 2011 20:41:21 +0200 Subject: [PATCH 2/3] Minor MSVC warning fixed Signed-off-by: Martin Sustrik --- src/xsub.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xsub.cpp b/src/xsub.cpp index 60ba598d..f4160c06 100644 --- a/src/xsub.cpp +++ b/src/xsub.cpp @@ -97,7 +97,9 @@ int zmq::xsub_t::xsend (msg_t *msg_, int flags_) else return 0; } + zmq_assert (false); + return -1; } bool zmq::xsub_t::xhas_out () From 9b795de4afdd5669a9000c5d13bec61e51fbba49 Mon Sep 17 00:00:00 2001 From: Steven McCoy Date: Sat, 18 Jun 2011 20:44:03 +0200 Subject: [PATCH 3/3] Refactor Windows versioning and WinSock usage.Signed-off-by: Steven McCoy --- include/zmq.h | 2 +- src/ctx.cpp | 14 ++--- src/select.cpp | 11 ++-- src/windows.hpp | 157 +++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 141 insertions(+), 43 deletions(-) diff --git a/include/zmq.h b/include/zmq.h index 8d1d57b1..e8454d83 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -28,7 +28,7 @@ extern "C" { #include #include #if defined _WIN32 -#include "winsock2.h" +#include #endif /* Handle DSO symbol visibility */ diff --git a/src/ctx.cpp b/src/ctx.cpp index fb5420dd..66255f02 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -18,24 +18,24 @@ along with this program. If not, see . */ +#include "platform.hpp" +#if defined ZMQ_HAVE_WINDOWS +#include "windows.hpp" +#else +#include +#endif + #include #include #include "ctx.hpp" #include "socket_base.hpp" #include "io_thread.hpp" -#include "platform.hpp" #include "reaper.hpp" #include "pipe.hpp" #include "err.hpp" #include "msg.hpp" -#if defined ZMQ_HAVE_WINDOWS -#include "windows.h" -#else -#include "unistd.h" -#endif - zmq::ctx_t::ctx_t (uint32_t io_threads_) : tag (0xbadcafe0), terminating (false) diff --git a/src/select.cpp b/src/select.cpp index 35d8bd87..5d5ce5d2 100644 --- a/src/select.cpp +++ b/src/select.cpp @@ -19,12 +19,8 @@ */ #include "platform.hpp" - -#include -#include - -#ifdef ZMQ_HAVE_WINDOWS -#include "winsock2.h" +#if defined ZMQ_HAVE_WINDOWS +#include "windows.hpp" #elif defined ZMQ_HAVE_HPUX #include #include @@ -36,6 +32,9 @@ #include #endif +#include +#include + #include "select.hpp" #include "err.hpp" #include "config.hpp" diff --git a/src/windows.hpp b/src/windows.hpp index 51338755..8f39914f 100644 --- a/src/windows.hpp +++ b/src/windows.hpp @@ -21,58 +21,157 @@ #ifndef __ZMQ_WINDOWS_HPP_INCLUDED__ #define __ZMQ_WINDOWS_HPP_INCLUDED__ -// The purpose of this header file is to turn on only the items actually needed -// on the windows platform. +// The purpose of this header file is to turn on only the items actually +// needed on the windows platform. -#define _WINSOCKAPI_ -#ifndef NOMINMAX -#define NOMINMAX // No min and max functions, these clash with C++. -#endif +// Disable deprecation warnings. #define _CRT_SECURE_NO_WARNINGS #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifndef NOUSER // No USER defines and routines. -#define NOUSER +#ifndef NOGDICAPMASKS +#define NOGDICAPMASKS // CC_*, LC_*, PC_*, CP_*, TC_*, RC_ #endif -#ifndef NOMCX // No Modem Configuration Extensions. -#define NOMCX +#ifndef NOVIRTUALKEYCODES +#define NOVIRTUALKEYCODES // VK_* #endif -#ifndef NOIME // No Input Method Editor. -#define NOIME +#ifndef NOWINMESSAGES +#define NOWINMESSAGES // WM_*, EM_*, LB_*, CB_* #endif -#ifndef NOSOUND // No Sound driver routines. -#define NOSOUND +#ifndef NOWINSTYLES +#define NOWINSTYLES // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_* +#endif +#ifndef NOSYSMETRICS +#define NOSYSMETRICS // SM_* +#endif +#ifndef NOMENUS +#define NOMENUS // MF_* +#endif +#ifndef NOICONS +#define NOICONS // IDI_* +#endif +#ifndef NOKEYSTATES +#define NOKEYSTATES // MK_* +#endif +#ifndef NOSYSCOMMANDS +#define NOSYSCOMMANDS // SC_* +#endif +#ifndef NORASTEROPS +#define NORASTEROPS // Binary and Tertiary raster ops +#endif +#ifndef NOSHOWWINDOW +#define NOSHOWWINDOW // SW_* +#endif +#ifndef OEMRESOURCE +#define OEMRESOURCE // OEM Resource values +#endif +#ifndef NOATOM +#define NOATOM // Atom Manager routines +#endif +#ifndef NOCLIPBOARD +#define NOCLIPBOARD // Clipboard routines +#endif +#ifndef NOCOLOR +#define NOCOLOR // Screen colors +#endif +#ifndef NOCTLMGR +#define NOCTLMGR // Control and Dialog routines +#endif +#ifndef NODRAWTEXT +#define NODRAWTEXT // DrawText() and DT_* +#endif +#ifndef NOGDI +#define NOGDI // All GDI defines and routines +#endif +#ifndef NOKERNEL +#define NOKERNEL // All KERNEL defines and routines +#endif +#ifndef NOUSER +#define NOUSER // All USER defines and routines +#endif +#ifndef NONLS +#define NONLS // All NLS defines and routines +#endif +#ifndef NOMB +#define NOMB // MB_* and MessageBox() +#endif +#ifndef NOMEMMGR +#define NOMEMMGR // GMEM_*, LMEM_*, GHND, LHND, associated routines +#endif +#ifndef NOMETAFILE +#define NOMETAFILE // typedef METAFILEPICT +#endif +#ifndef NOMINMAX +#define NOMINMAX // Macros min(a,b) and max(a,b) +#endif +#ifndef NOMSG +#define NOMSG // typedef MSG and associated routines +#endif +#ifndef NOOPENFILE +#define NOOPENFILE // OpenFile(), OemToAnsi, AnsiToOem, and OF_* +#endif +#ifndef NOSCROLL +#define NOSCROLL // SB_* and scrolling routines +#endif +#ifndef NOSERVICE +#define NOSERVICE // All Service Controller routines, SERVICE_ equates, etc. +#endif +#ifndef NOSOUND +#define NOSOUND // Sound driver routines +#endif +#ifndef NOTEXTMETRIC +#define NOTEXTMETRIC // typedef TEXTMETRIC and associated routines +#endif +#ifndef NOWH +#define NOWH // SetWindowsHook and WH_* +#endif +#ifndef NOWINOFFSETS +#define NOWINOFFSETS // GWL_*, GCL_*, associated routines +#endif +#ifndef NOCOMM +#define NOCOMM // COMM driver routines +#endif +#ifndef NOKANJI +#define NOKANJI // Kanji support stuff. +#endif +#ifndef NOHELP +#define NOHELP // Help engine interface. +#endif +#ifndef NOPROFILER +#define NOPROFILER // Profiler interface. +#endif +#ifndef NODEFERWINDOWPOS +#define NODEFERWINDOWPOS // DeferWindowPos routines +#endif +#ifndef NOMCX +#define NOMCX // Modem Configuration ExtensionsA #endif -#ifdef ZMQ_HAVE_MINGW32 -#ifdef WINVER -#undef WINVER -#endif -#define WINVER 0x0501 +// Set target version to Windows Server 2003, Windows XP/SP1 or higher. +#ifndef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 #endif #include -// MSVC++ 2005 on Win2000 does not define _WIN32_WINNT. -#ifndef _WIN32_WINNT -#define _WIN32_WINNT WINVER +#ifdef __MINGW32__ +// Require Windows XP or higher with MinGW for getaddrinfo(). +#if(_WIN32_WINNT >= 0x0501) +#else +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0501 #endif - -// Enable winsock (not included when WIN32_LEAN_AND_MEAN is defined). -#if(_WIN32_WINNT >= 0x0400) +#endif + #include #include -#else -#include -#endif #include #include #include -// On mingw environment AI_NUMERICSERV is not defined, needed in ip.cpp. +// In MinGW environment AI_NUMERICSERV is not defined. #ifndef AI_NUMERICSERV #define AI_NUMERICSERV 0x0400 #endif