Unverified Commit 21f642fa authored by Simon Giesecke's avatar Simon Giesecke Committed by GitHub

Merge pull request #3092 from bluca/solaris_studio

Problem: build broken on Solaris with Sun Studio compilers
parents 15e8de2f c5b7f4f5
......@@ -40,7 +40,18 @@
#define ZMQ_PUSH_OR_EMPLACE_BACK emplace_back
#define ZMQ_MOVE(x) std::move (x)
#else
#if defined ZMQ_HAVE_SOLARIS
template <typename K, typename V>
std::pair<const K, V> make_pair_fix_const (const K &k, const V &v)
{
return std::pair<const K, V> (k, v);
}
#define ZMQ_MAP_INSERT_OR_EMPLACE(k, v) insert (make_pair_fix_const (k, v))
#else
#define ZMQ_MAP_INSERT_OR_EMPLACE(k, v) insert (std::make_pair (k, v))
#endif
#define ZMQ_PUSH_OR_EMPLACE_BACK push_back
#define ZMQ_MOVE(x) (x)
#endif
......
......@@ -503,7 +503,8 @@ int zmq::ctx_t::register_endpoint (const char *addr_,
scoped_lock_t locker (endpoints_sync);
const bool inserted =
endpoints.ZMQ_MAP_INSERT_OR_EMPLACE (addr_, endpoint_).second;
endpoints.ZMQ_MAP_INSERT_OR_EMPLACE (std::string (addr_), endpoint_)
.second;
if (!inserted) {
errno = EADDRINUSE;
return -1;
......
......@@ -62,7 +62,8 @@ void zmq::mechanism_t::set_user_id (const void *data_, size_t size_)
{
user_id.set (static_cast<const unsigned char *> (data_), size_);
zap_properties.ZMQ_MAP_INSERT_OR_EMPLACE (
ZMQ_MSG_PROPERTY_USER_ID, std::string ((char *) data_, size_));
std::string (ZMQ_MSG_PROPERTY_USER_ID),
std::string ((char *) data_, size_));
}
const zmq::blob_t &zmq::mechanism_t::get_user_id () const
......
......@@ -288,11 +288,11 @@ int do_getsockopt (void *const optval_,
int do_setsockopt_int_as_bool_strict (const void *const optval_,
const size_t optvallen_,
bool *out_value_);
bool *const out_value_);
int do_setsockopt_int_as_bool_relaxed (const void *const optval_,
const size_t optvallen_,
bool *out_value_);
bool *const out_value_);
}
#endif
......@@ -783,7 +783,7 @@ int zmq::socket_base_t::connect (const char *addr_)
last_endpoint.assign (addr_);
// remember inproc connections for disconnect
inprocs.ZMQ_MAP_INSERT_OR_EMPLACE (addr_, new_pipes[0]);
inprocs.ZMQ_MAP_INSERT_OR_EMPLACE (std::string (addr_), new_pipes[0]);
options.connected = true;
return 0;
......@@ -982,7 +982,7 @@ void zmq::socket_base_t::add_endpoint (const char *addr_,
{
// Activate the session. Make it a child of this socket.
launch_child (endpoint_);
endpoints.ZMQ_MAP_INSERT_OR_EMPLACE (addr_,
endpoints.ZMQ_MAP_INSERT_OR_EMPLACE (std::string (addr_),
endpoint_pipe_t (endpoint_, pipe));
}
......
......@@ -999,14 +999,15 @@ bool zmq::stream_engine_t::init_properties (properties_t &properties)
{
if (peer_address.empty ())
return false;
properties.ZMQ_MAP_INSERT_OR_EMPLACE (ZMQ_MSG_PROPERTY_PEER_ADDRESS,
peer_address);
properties.ZMQ_MAP_INSERT_OR_EMPLACE (
std::string (ZMQ_MSG_PROPERTY_PEER_ADDRESS), peer_address);
// Private property to support deprecated SRCFD
std::ostringstream stream;
stream << (int) s;
std::string fd_string = stream.str ();
properties.ZMQ_MAP_INSERT_OR_EMPLACE ("__fd", ZMQ_MOVE (fd_string));
properties.ZMQ_MAP_INSERT_OR_EMPLACE (std::string ("__fd"),
ZMQ_MOVE (fd_string));
return true;
}
......
......@@ -67,7 +67,7 @@ int tcp_read (fd_t s_, void *data_, size_t size_);
// on network errors such as reset or aborted connections.
void tcp_assert_tuning_error (fd_t s_, int rc_);
void tcp_tune_loopback_fast_path (fd_t socket_);
void tcp_tune_loopback_fast_path (const fd_t socket_);
}
#endif
......@@ -38,6 +38,13 @@
#include <unistd.h>
#endif
// Solaris has a default of 256 max files per process
#ifdef ZMQ_HAVE_SOLARIS
#define MAX_SOCKETS 200
#else
#define MAX_SOCKETS 1000
#endif
#if defined(ZMQ_HAVE_WINDOWS)
void initialise_network (void)
......@@ -75,24 +82,22 @@ int main (void)
return -1;
}
// Check that we can create 1,000 sockets
int handle[1000];
int handle[MAX_SOCKETS];
int count;
for (count = 0; count < 1000; count++) {
for (count = 0; count < MAX_SOCKETS; count++) {
handle[count] = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (handle[count] == -1) {
printf ("W: Only able to create %d sockets on this box\n", count);
printf (
"I: Tune your system to increase maximum allowed file handles\n");
#if defined(ZMQ_HAVE_OSX)
printf ("I: On OS/X, run 'ulimit -n 1200' in bash\n");
#elif defined(ZMQ_HAVE_LINUX)
printf ("I: On Linux, run 'ulimit -n 1200' in bash\n");
#if !defined(ZMQ_HAVE_WINDOWS)
printf ("I: Run 'ulimit -n 1200' in bash\n");
#endif
return -1;
}
}
// Release the socket handles
for (count = 0; count < 1000; count++) {
for (count = 0; count < MAX_SOCKETS; count++) {
close (handle[count]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment