Merge remote-tracking branch 'upstream/master'

This commit is contained in:
czach 2014-03-13 11:11:17 +01:00
commit 03a3dd2503
11 changed files with 45 additions and 27 deletions

View File

@ -37,6 +37,7 @@ Dhammika Pathirana <dhammika@gmail.com>
Dhruva Krishnamurthy <dhruva@ymail.com>
Dirk O. Kaar <dok@dok-net.net>
Douglas Creager <douglas.creager@redjack.com>
Drew Crawford <drew@sealedabstract.com>
Erich Heine <sophacles@gmail.com>
Erik Hugne <erik.hugne@ericsson.com>
Erik Rigtorp <erik@rigtorp.com>

View File

@ -299,7 +299,12 @@ esac
# Checks for libraries
AC_CHECK_LIB([pthread], [pthread_create])
AC_CHECK_LIB([rt], [clock_gettime])
AC_CHECK_LIB([sodium], [sodium_init],,AC_MSG_WARN(libsodium is needed for CURVE security))
if test "x$zmq_search_libsodium" = "xyes"; then
AC_CHECK_LIB([sodium], [sodium_init],,AC_MSG_ERROR(libsodium is not installed. Install it or don't pass --with-libsodium to configure script))
else
AC_CHECK_LIB([sodium], [sodium_init],,AC_MSG_WARN(libsodium is needed for CURVE security))
fi
#
# Check if the compiler supports -fvisibility=hidden flag. MinGW32 uses __declspec

View File

@ -382,7 +382,7 @@ ZMQ_EXPORT int zmq_recviov (void *s, struct iovec *iov, size_t *count, int flags
#define ZMQ_POLLOUT 2
#define ZMQ_POLLERR 4
typedef struct
typedef struct zmq_pollitem_t
{
void *socket;
#if defined _WIN32

View File

@ -240,7 +240,7 @@ int zmq::req_t::recv_reply_pipe (msg_t *msg_)
zmq::req_session_t::req_session_t (io_thread_t *io_thread_, bool connect_,
socket_base_t *socket_, const options_t &options_,
const address_t *addr_) :
address_t *addr_) :
session_base_t (io_thread_, connect_, socket_, options_, addr_),
state (bottom)
{

View File

@ -87,7 +87,7 @@ namespace zmq
req_session_t (zmq::io_thread_t *io_thread_, bool connect_,
zmq::socket_base_t *socket_, const options_t &options_,
const address_t *addr_);
address_t *addr_);
~req_session_t ();
// Overrides of the functions from session_base_t.

View File

@ -34,7 +34,7 @@
zmq::session_base_t *zmq::session_base_t::create (class io_thread_t *io_thread_,
bool active_, class socket_base_t *socket_, const options_t &options_,
const address_t *addr_)
address_t *addr_)
{
session_base_t *s = NULL;
@ -67,7 +67,7 @@ zmq::session_base_t *zmq::session_base_t::create (class io_thread_t *io_thread_,
zmq::session_base_t::session_base_t (class io_thread_t *io_thread_,
bool active_, class socket_base_t *socket_, const options_t &options_,
const address_t *addr_) :
address_t *addr_) :
own_t (io_thread_, options_),
io_object_t (io_thread_),
active (active_),

View File

@ -47,7 +47,7 @@ namespace zmq
// Create a session of the particular type.
static session_base_t *create (zmq::io_thread_t *io_thread_,
bool active_, zmq::socket_base_t *socket_,
const options_t &options_, const address_t *addr_);
const options_t &options_, address_t *addr_);
// To be used once only, when creating the session.
void attach_pipe (zmq::pipe_t *pipe_);
@ -90,7 +90,7 @@ namespace zmq
session_base_t (zmq::io_thread_t *io_thread_, bool active_,
zmq::socket_base_t *socket_, const options_t &options_,
const address_t *addr_);
address_t *addr_);
virtual ~session_base_t ();
private:
@ -152,7 +152,7 @@ namespace zmq
bool has_linger_timer;
// Protocol and address to use when connecting.
const address_t *addr;
address_t *addr;
session_base_t (const session_base_t&);
const session_base_t &operator = (const session_base_t&);

View File

@ -588,14 +588,8 @@ int zmq::socket_base_t::connect (const char *addr_)
// Resolve address (if needed by the protocol)
if (protocol == "tcp") {
paddr->resolved.tcp_addr = new (std::nothrow) tcp_address_t ();
alloc_assert (paddr->resolved.tcp_addr);
int rc = paddr->resolved.tcp_addr->resolve (
address.c_str (), false, options.ipv6);
if (rc != 0) {
delete paddr;
return -1;
}
// Defer resolution until a socket is opened
paddr->resolved.tcp_addr = NULL;
}
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS
else

View File

@ -50,7 +50,7 @@
zmq::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
class session_base_t *session_, const options_t &options_,
const address_t *addr_, bool delayed_start_) :
address_t *addr_, bool delayed_start_) :
own_t (io_thread_, options_),
io_object_t (io_thread_),
addr (addr_),
@ -209,6 +209,24 @@ int zmq::tcp_connecter_t::open ()
{
zmq_assert (s == retired_fd);
// Resolve the address
if (addr->resolved.tcp_addr != NULL) {
delete addr->resolved.tcp_addr;
addr->resolved.tcp_addr = NULL;
}
zmq_assert (addr->resolved.tcp_addr == NULL);
addr->resolved.tcp_addr = new (std::nothrow) tcp_address_t ();
alloc_assert (addr->resolved.tcp_addr);
int rc = addr->resolved.tcp_addr->resolve (
addr->address.c_str (), false, options.ipv6);
if (rc != 0) {
delete addr->resolved.tcp_addr;
addr->resolved.tcp_addr = NULL;
return -1;
}
zmq_assert (addr->resolved.tcp_addr != NULL);
// Create the socket.
s = open_socket (addr->resolved.tcp_addr->family (), SOCK_STREAM, IPPROTO_TCP);
#ifdef ZMQ_HAVE_WINDOWS
@ -244,7 +262,7 @@ int zmq::tcp_connecter_t::open ()
set_ip_type_of_service (s, options.tos);
// Connect to the remote peer.
int rc = ::connect (
rc = ::connect (
s, addr->resolved.tcp_addr->addr (),
addr->resolved.tcp_addr->addrlen ());

View File

@ -41,7 +41,7 @@ namespace zmq
// then starts connection process.
tcp_connecter_t (zmq::io_thread_t *io_thread_,
zmq::session_base_t *session_, const options_t &options_,
const address_t *addr_, bool delayed_start_);
address_t *addr_, bool delayed_start_);
~tcp_connecter_t ();
private:
@ -82,7 +82,7 @@ namespace zmq
fd_t connect ();
// Address to connect to. Owned by session_base_t.
const address_t *addr;
address_t *addr;
// Underlying socket.
fd_t s;

View File

@ -30,15 +30,15 @@ int main (void)
int rc = zmq_connect (sock, "tcp://localhost:1234");
assert (rc == 0);
// Because of lazy resolution of TCP names, this will succeed
rc = zmq_connect (sock, "tcp://localhost:invalid");
assert (rc == -1);
assert (errno == EINVAL);
assert (rc == 0);
// Because of lazy resolution of TCP names, this will succeed
rc = zmq_connect (sock, "tcp://in val id:1234");
assert (rc == -1);
assert (errno == EINVAL);
assert (rc == 0);
rc = zmq_connect (sock, "invalid://localhost:1234");
assert (rc == -1);
assert (errno == EPROTONOSUPPORT);