mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-09 15:26:04 +00:00
Merge pull request #1823 from opedroso/COVERITY
Problem: Several problems found by Coverity Static Analyzer
This commit is contained in:
commit
406b5738b6
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}</ProjectGuid>
|
<ProjectGuid>{6FF7436F-B3F6-4AE9-A3AC-CFDE8A3872A0}</ProjectGuid>
|
||||||
<ProjectName>inproc_lat</ProjectName>
|
<ProjectName>inproc_lat</ProjectName>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{1077E977-95DD-4E73-A692-74647DD0CC1E}</ProjectGuid>
|
<ProjectGuid>{1077E977-95DD-4E73-A692-74647DD0CC1E}</ProjectGuid>
|
||||||
<ProjectName>inproc_thr</ProjectName>
|
<ProjectName>inproc_thr</ProjectName>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{641C5F36-32EE-4323-B740-992B651CF9D6}</ProjectGuid>
|
<ProjectGuid>{641C5F36-32EE-4323-B740-992B651CF9D6}</ProjectGuid>
|
||||||
<ProjectName>libzmq</ProjectName>
|
<ProjectName>libzmq</ProjectName>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{4FDB8C73-9D4A-4D87-A4A9-A7FC06DFEA57}</ProjectGuid>
|
<ProjectGuid>{4FDB8C73-9D4A-4D87-A4A9-A7FC06DFEA57}</ProjectGuid>
|
||||||
<ProjectName>local_lat</ProjectName>
|
<ProjectName>local_lat</ProjectName>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{8EF2DF6B-6646-460F-8032-913B70FE0E94}</ProjectGuid>
|
<ProjectGuid>{8EF2DF6B-6646-460F-8032-913B70FE0E94}</ProjectGuid>
|
||||||
<ProjectName>local_thr</ProjectName>
|
<ProjectName>local_thr</ProjectName>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{9C20A37C-5D9F-4C4C-A2D9-E6EE91A077D1}</ProjectGuid>
|
<ProjectGuid>{9C20A37C-5D9F-4C4C-A2D9-E6EE91A077D1}</ProjectGuid>
|
||||||
<ProjectName>remote_lat</ProjectName>
|
<ProjectName>remote_lat</ProjectName>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{B15E059C-0CBB-4A82-8C42-6567FB650802}</ProjectGuid>
|
<ProjectGuid>{B15E059C-0CBB-4A82-8C42-6567FB650802}</ProjectGuid>
|
||||||
<ProjectName>remote_thr</ProjectName>
|
<ProjectName>remote_thr</ProjectName>
|
||||||
|
@ -108,6 +108,8 @@ f_compatible_get_tick_count64 init_compatible_get_tick_count64()
|
|||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
func = compatible_get_tick_count64;
|
func = compatible_get_tick_count64;
|
||||||
|
|
||||||
|
::FreeLibrary(module);
|
||||||
|
|
||||||
return func;
|
return func;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/dish.cpp
12
src/dish.cpp
@ -332,13 +332,15 @@ int zmq::dish_session_t::pull_msg (msg_t *msg_)
|
|||||||
int offset;
|
int offset;
|
||||||
|
|
||||||
if (msg_->is_join ()) {
|
if (msg_->is_join ()) {
|
||||||
command.init_size (group_length + 5);
|
rc = command.init_size (group_length + 5);
|
||||||
offset = 5;
|
errno_assert(rc == 0);
|
||||||
|
offset = 5;
|
||||||
memcpy (command.data (), "\4JOIN", 5);
|
memcpy (command.data (), "\4JOIN", 5);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
command.init_size (group_length + 6);
|
rc = command.init_size (group_length + 6);
|
||||||
offset = 6;
|
errno_assert(rc == 0);
|
||||||
|
offset = 6;
|
||||||
memcpy (command.data (), "\5LEAVE", 6);
|
memcpy (command.data (), "\5LEAVE", 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +351,7 @@ int zmq::dish_session_t::pull_msg (msg_t *msg_)
|
|||||||
memcpy (command_data + offset, msg_->group (), group_length);
|
memcpy (command_data + offset, msg_->group (), group_length);
|
||||||
|
|
||||||
// Close the join message
|
// Close the join message
|
||||||
int rc = msg_->close ();
|
rc = msg_->close ();
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
*msg_ = command;
|
*msg_ = command;
|
||||||
|
@ -58,6 +58,10 @@ namespace zmq
|
|||||||
|
|
||||||
inline encoder_base_t (size_t bufsize_) :
|
inline encoder_base_t (size_t bufsize_) :
|
||||||
bufsize (bufsize_),
|
bufsize (bufsize_),
|
||||||
|
write_pos(0),
|
||||||
|
to_write(0),
|
||||||
|
next(nullptr),
|
||||||
|
new_msg_flag(false),
|
||||||
in_progress (NULL)
|
in_progress (NULL)
|
||||||
{
|
{
|
||||||
buf = (unsigned char*) malloc (bufsize_);
|
buf = (unsigned char*) malloc (bufsize_);
|
||||||
|
@ -157,7 +157,7 @@ int zmq::null_mechanism_t::process_handshake_command (msg_t *msg_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
int rc = msg_->close ();
|
rc = msg_->close ();
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
rc = msg_->init ();
|
rc = msg_->init ();
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
@ -92,6 +92,7 @@ zmq::pipe_t::pipe_t (object_t *parent_, upipe_t *inpipe_, upipe_t *outpipe_,
|
|||||||
sink (NULL),
|
sink (NULL),
|
||||||
state (active),
|
state (active),
|
||||||
delay (true),
|
delay (true),
|
||||||
|
routing_id(0),
|
||||||
conflate (conflate_)
|
conflate (conflate_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ void zmq::poller_base_t::adjust_load (int amount_)
|
|||||||
load.add (amount_);
|
load.add (amount_);
|
||||||
else
|
else
|
||||||
if (amount_ < 0)
|
if (amount_ < 0)
|
||||||
load.sub (-amount_);
|
bool reset = load.sub (-amount_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::poller_base_t::add_timer (int timeout_, i_poll_events *sink_, int id_)
|
void zmq::poller_base_t::add_timer (int timeout_, i_poll_events *sink_, int id_)
|
||||||
|
@ -227,8 +227,9 @@ int zmq::radio_session_t::pull_msg (msg_t *msg_)
|
|||||||
int length = (int) strlen (group);
|
int length = (int) strlen (group);
|
||||||
|
|
||||||
// First frame is the group
|
// First frame is the group
|
||||||
msg_->init_size (length);
|
rc = msg_->init_size (length);
|
||||||
msg_->set_flags (msg_t::more);
|
errno_assert(rc == 0);
|
||||||
|
msg_->set_flags(msg_t::more);
|
||||||
memcpy (msg_->data (), group, length);
|
memcpy (msg_->data (), group, length);
|
||||||
|
|
||||||
// Next status is the body
|
// Next status is the body
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
zmq::reaper_t::reaper_t (class ctx_t *ctx_, uint32_t tid_) :
|
zmq::reaper_t::reaper_t (class ctx_t *ctx_, uint32_t tid_) :
|
||||||
object_t (ctx_, tid_),
|
object_t (ctx_, tid_),
|
||||||
sockets (0),
|
sockets (0),
|
||||||
|
mailbox_handle(NULL),
|
||||||
terminating (false)
|
terminating (false)
|
||||||
{
|
{
|
||||||
poller = new (std::nothrow) poller_t (*ctx_);
|
poller = new (std::nothrow) poller_t (*ctx_);
|
||||||
|
@ -155,9 +155,9 @@ void zmq::router_t::xpipe_terminated (pipe_t *pipe_)
|
|||||||
if (it != anonymous_pipes.end ())
|
if (it != anonymous_pipes.end ())
|
||||||
anonymous_pipes.erase (it);
|
anonymous_pipes.erase (it);
|
||||||
else {
|
else {
|
||||||
outpipes_t::iterator it = outpipes.find (pipe_->get_identity ());
|
outpipes_t::iterator iter = outpipes.find (pipe_->get_identity ());
|
||||||
zmq_assert (it != outpipes.end ());
|
zmq_assert (iter != outpipes.end ());
|
||||||
outpipes.erase (it);
|
outpipes.erase (iter);
|
||||||
fq.pipe_terminated (pipe_);
|
fq.pipe_terminated (pipe_);
|
||||||
if (pipe_ == current_out)
|
if (pipe_ == current_out)
|
||||||
current_out = NULL;
|
current_out = NULL;
|
||||||
|
@ -122,7 +122,7 @@ int zmq::server_t::xsend (msg_t *msg_)
|
|||||||
bool ok = it->second.pipe->write (msg_);
|
bool ok = it->second.pipe->write (msg_);
|
||||||
if (unlikely (!ok)) {
|
if (unlikely (!ok)) {
|
||||||
// Message failed to send - we must close it ourselves.
|
// Message failed to send - we must close it ourselves.
|
||||||
int rc = msg_->close ();
|
rc = msg_->close ();
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -539,7 +539,8 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
|||||||
saved_errno = WSAGetLastError ();
|
saved_errno = WSAGetLastError ();
|
||||||
|
|
||||||
// We don't need the listening socket anymore. Close it.
|
// We don't need the listening socket anymore. Close it.
|
||||||
closesocket (listener);
|
rc = closesocket (listener);
|
||||||
|
wsa_assert(rc != SOCKET_ERROR);
|
||||||
|
|
||||||
if (sync != NULL) {
|
if (sync != NULL) {
|
||||||
// Exit the critical section.
|
// Exit the critical section.
|
||||||
|
@ -191,6 +191,8 @@ zmq::socket_base_t::socket_base_t (ctx_t *parent_, uint32_t tid_, int sid_, bool
|
|||||||
monitor_socket (NULL),
|
monitor_socket (NULL),
|
||||||
monitor_events (0),
|
monitor_events (0),
|
||||||
thread_safe (thread_safe_),
|
thread_safe (thread_safe_),
|
||||||
|
poller(nullptr),
|
||||||
|
handle(NULL),
|
||||||
reaper_signaler (NULL)
|
reaper_signaler (NULL)
|
||||||
{
|
{
|
||||||
options.socket_id = sid_;
|
options.socket_id = sid_;
|
||||||
@ -452,7 +454,7 @@ int zmq::socket_base_t::getsockopt (int option_, void *optval_,
|
|||||||
EXIT_MUTEX ();
|
EXIT_MUTEX ();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
strcpy (static_cast <char *> (optval_), last_endpoint.c_str ());
|
strncpy(static_cast <char *> (optval_), last_endpoint.c_str(), last_endpoint.size() + 1);
|
||||||
*optvallen_ = last_endpoint.size () + 1;
|
*optvallen_ = last_endpoint.size () + 1;
|
||||||
EXIT_MUTEX ();
|
EXIT_MUTEX ();
|
||||||
return 0;
|
return 0;
|
||||||
@ -557,7 +559,7 @@ int zmq::socket_base_t::bind (const char *addr_)
|
|||||||
|
|
||||||
if (protocol == "inproc") {
|
if (protocol == "inproc") {
|
||||||
const endpoint_t endpoint = { this, options };
|
const endpoint_t endpoint = { this, options };
|
||||||
const int rc = register_endpoint (addr_, endpoint);
|
rc = register_endpoint (addr_, endpoint);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
connect_pending (addr_, this);
|
connect_pending (addr_, this);
|
||||||
last_endpoint.assign (addr_);
|
last_endpoint.assign (addr_);
|
||||||
@ -590,7 +592,7 @@ int zmq::socket_base_t::bind (const char *addr_)
|
|||||||
tcp_listener_t *listener = new (std::nothrow) tcp_listener_t (
|
tcp_listener_t *listener = new (std::nothrow) tcp_listener_t (
|
||||||
io_thread, this, options);
|
io_thread, this, options);
|
||||||
alloc_assert (listener);
|
alloc_assert (listener);
|
||||||
int rc = listener->set_address (address.c_str ());
|
rc = listener->set_address (address.c_str ());
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
LIBZMQ_DELETE(listener);
|
LIBZMQ_DELETE(listener);
|
||||||
event_bind_failed (address, zmq_errno());
|
event_bind_failed (address, zmq_errno());
|
||||||
@ -739,7 +741,7 @@ int zmq::socket_base_t::connect (const char *addr_)
|
|||||||
|
|
||||||
int hwms [2] = {conflate? -1 : sndhwm, conflate? -1 : rcvhwm};
|
int hwms [2] = {conflate? -1 : sndhwm, conflate? -1 : rcvhwm};
|
||||||
bool conflates [2] = {conflate, conflate};
|
bool conflates [2] = {conflate, conflate};
|
||||||
int rc = pipepair (parents, new_pipes, hwms, conflates);
|
rc = pipepair (parents, new_pipes, hwms, conflates);
|
||||||
if (!conflate) {
|
if (!conflate) {
|
||||||
new_pipes[0]->set_hwms_boost(peer.options.sndhwm, peer.options.rcvhwm);
|
new_pipes[0]->set_hwms_boost(peer.options.sndhwm, peer.options.rcvhwm);
|
||||||
new_pipes[1]->set_hwms_boost(options.sndhwm, options.rcvhwm);
|
new_pipes[1]->set_hwms_boost(options.sndhwm, options.rcvhwm);
|
||||||
@ -894,7 +896,7 @@ int zmq::socket_base_t::connect (const char *addr_)
|
|||||||
if (protocol == "udp") {
|
if (protocol == "udp") {
|
||||||
paddr->resolved.udp_addr = new (std::nothrow) udp_address_t ();
|
paddr->resolved.udp_addr = new (std::nothrow) udp_address_t ();
|
||||||
alloc_assert (paddr->resolved.udp_addr);
|
alloc_assert (paddr->resolved.udp_addr);
|
||||||
int rc = paddr->resolved.udp_addr->resolve (address.c_str());
|
rc = paddr->resolved.udp_addr->resolve (address.c_str());
|
||||||
if (rc != 0) {
|
if (rc != 0) {
|
||||||
LIBZMQ_DELETE(paddr);
|
LIBZMQ_DELETE(paddr);
|
||||||
EXIT_MUTEX ();
|
EXIT_MUTEX ();
|
||||||
@ -1501,9 +1503,10 @@ void zmq::socket_base_t::in_event ()
|
|||||||
if (thread_safe)
|
if (thread_safe)
|
||||||
reaper_signaler->recv();
|
reaper_signaler->recv();
|
||||||
|
|
||||||
process_commands (0, false);
|
int rc = process_commands (0, false);
|
||||||
EXIT_MUTEX ();
|
EXIT_MUTEX();
|
||||||
check_destroy ();
|
errno_assert(rc == 0);
|
||||||
|
check_destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::socket_base_t::out_event ()
|
void zmq::socket_base_t::out_event ()
|
||||||
|
@ -34,12 +34,20 @@
|
|||||||
zmq::socket_poller_t::socket_poller_t () :
|
zmq::socket_poller_t::socket_poller_t () :
|
||||||
tag (0xCAFEBABE),
|
tag (0xCAFEBABE),
|
||||||
need_rebuild (true),
|
need_rebuild (true),
|
||||||
|
poll_size(0),
|
||||||
|
maxfd(0),
|
||||||
use_signaler (false)
|
use_signaler (false)
|
||||||
#if defined ZMQ_POLL_BASED_ON_POLL
|
#if defined ZMQ_POLL_BASED_ON_POLL
|
||||||
,
|
,
|
||||||
pollfds (NULL)
|
pollfds (NULL)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
#if defined ZMQ_POLL_BASED_ON_SELECT
|
||||||
|
memset(&pollset_in, 0, sizeof(pollset_in));
|
||||||
|
memset(&pollset_out, 0, sizeof(pollset_in));
|
||||||
|
memset(&pollset_err, 0, sizeof(pollset_in));
|
||||||
|
maxfd = 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
zmq::socket_poller_t::~socket_poller_t ()
|
zmq::socket_poller_t::~socket_poller_t ()
|
||||||
|
@ -63,6 +63,9 @@ zmq::socks_connecter_t::socks_connecter_t (class io_thread_t *io_thread_,
|
|||||||
s (retired_fd),
|
s (retired_fd),
|
||||||
delayed_start (delayed_start_),
|
delayed_start (delayed_start_),
|
||||||
session (session_),
|
session (session_),
|
||||||
|
handle(NULL),
|
||||||
|
handle_valid(false),
|
||||||
|
timer_started(false),
|
||||||
current_reconnect_ivl (options.reconnect_ivl)
|
current_reconnect_ivl (options.reconnect_ivl)
|
||||||
{
|
{
|
||||||
zmq_assert (addr);
|
zmq_assert (addr);
|
||||||
@ -113,13 +116,13 @@ void zmq::socks_connecter_t::in_event ()
|
|||||||
&& status != waiting_for_reconnect_time);
|
&& status != waiting_for_reconnect_time);
|
||||||
|
|
||||||
if (status == waiting_for_choice) {
|
if (status == waiting_for_choice) {
|
||||||
const int rc = choice_decoder.input (s);
|
int rc = choice_decoder.input (s);
|
||||||
if (rc == 0 || rc == -1)
|
if (rc == 0 || rc == -1)
|
||||||
error ();
|
error ();
|
||||||
else
|
else
|
||||||
if (choice_decoder.message_ready ()) {
|
if (choice_decoder.message_ready ()) {
|
||||||
const socks_choice_t choice = choice_decoder.decode ();
|
const socks_choice_t choice = choice_decoder.decode ();
|
||||||
const int rc = process_server_response (choice);
|
rc = process_server_response (choice);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
error ();
|
error ();
|
||||||
else {
|
else {
|
||||||
@ -139,13 +142,13 @@ void zmq::socks_connecter_t::in_event ()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (status == waiting_for_response) {
|
if (status == waiting_for_response) {
|
||||||
const int rc = response_decoder.input (s);
|
int rc = response_decoder.input (s);
|
||||||
if (rc == 0 || rc == -1)
|
if (rc == 0 || rc == -1)
|
||||||
error ();
|
error ();
|
||||||
else
|
else
|
||||||
if (response_decoder.message_ready ()) {
|
if (response_decoder.message_ready ()) {
|
||||||
const socks_response_t response = response_decoder.decode ();
|
const socks_response_t response = response_decoder.decode ();
|
||||||
const int rc = process_server_response (response);
|
rc = process_server_response (response);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
error ();
|
error ();
|
||||||
else {
|
else {
|
||||||
|
@ -87,6 +87,8 @@ zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_,
|
|||||||
has_timeout_timer (false),
|
has_timeout_timer (false),
|
||||||
has_heartbeat_timer (false),
|
has_heartbeat_timer (false),
|
||||||
heartbeat_timeout (0),
|
heartbeat_timeout (0),
|
||||||
|
as_server(false),
|
||||||
|
handle(NULL),
|
||||||
socket (NULL)
|
socket (NULL)
|
||||||
{
|
{
|
||||||
int rc = tx_msg.init ();
|
int rc = tx_msg.init ();
|
||||||
@ -1018,8 +1020,9 @@ int zmq::stream_engine_t::produce_ping_message(msg_t * msg_)
|
|||||||
zmq_assert (mechanism != NULL);
|
zmq_assert (mechanism != NULL);
|
||||||
|
|
||||||
// 16-bit TTL + \4PING == 7
|
// 16-bit TTL + \4PING == 7
|
||||||
msg_->init_size(7);
|
rc = msg_->init_size(7);
|
||||||
msg_->set_flags(msg_t::command);
|
errno_assert(rc == 0);
|
||||||
|
msg_->set_flags(msg_t::command);
|
||||||
// Copy in the command message
|
// Copy in the command message
|
||||||
memcpy(msg_->data(), "\4PING", 5);
|
memcpy(msg_->data(), "\4PING", 5);
|
||||||
|
|
||||||
@ -1040,8 +1043,9 @@ int zmq::stream_engine_t::produce_pong_message(msg_t * msg_)
|
|||||||
int rc = 0;
|
int rc = 0;
|
||||||
zmq_assert (mechanism != NULL);
|
zmq_assert (mechanism != NULL);
|
||||||
|
|
||||||
msg_->init_size(5);
|
rc = msg_->init_size(5);
|
||||||
msg_->set_flags(msg_t::command);
|
errno_assert(rc == 0);
|
||||||
|
msg_->set_flags(msg_t::command);
|
||||||
|
|
||||||
memcpy(msg_->data(), "\4PONG", 5);
|
memcpy(msg_->data(), "\4PONG", 5);
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ zmq::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
|
|||||||
connect_timer_started (false),
|
connect_timer_started (false),
|
||||||
reconnect_timer_started (false),
|
reconnect_timer_started (false),
|
||||||
session (session_),
|
session (session_),
|
||||||
|
handle(NULL),
|
||||||
current_reconnect_ivl (options.reconnect_ivl)
|
current_reconnect_ivl (options.reconnect_ivl)
|
||||||
{
|
{
|
||||||
zmq_assert (addr);
|
zmq_assert (addr);
|
||||||
|
@ -65,6 +65,7 @@ zmq::tcp_listener_t::tcp_listener_t (io_thread_t *io_thread_,
|
|||||||
own_t (io_thread_, options_),
|
own_t (io_thread_, options_),
|
||||||
io_object_t (io_thread_),
|
io_object_t (io_thread_),
|
||||||
s (retired_fd),
|
s (retired_fd),
|
||||||
|
handle(NULL),
|
||||||
socket (socket_)
|
socket (socket_)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,9 @@ namespace zmq
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
inline thread_t ()
|
inline thread_t ()
|
||||||
|
: tfn(nullptr)
|
||||||
|
, arg(nullptr)
|
||||||
|
, descriptor(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
zmq::udp_address_t::udp_address_t ()
|
zmq::udp_address_t::udp_address_t ()
|
||||||
|
: is_mutlicast(false)
|
||||||
{
|
{
|
||||||
memset (&bind_address, 0, sizeof bind_address);
|
memset (&bind_address, 0, sizeof bind_address);
|
||||||
memset (&dest_address, 0, sizeof dest_address);
|
memset (&dest_address, 0, sizeof dest_address);
|
||||||
|
@ -48,6 +48,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
zmq::udp_engine_t::udp_engine_t() :
|
zmq::udp_engine_t::udp_engine_t() :
|
||||||
plugged (false),
|
plugged (false),
|
||||||
|
fd(NULL),
|
||||||
|
address(nullptr),
|
||||||
|
send_enabled(false),
|
||||||
|
recv_enabled(false),
|
||||||
|
handle(NULL),
|
||||||
session(NULL)
|
session(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -122,7 +127,7 @@ void zmq::udp_engine_t::plug (io_thread_t* io_thread_, session_base_t *session_)
|
|||||||
struct ip_mreq mreq;
|
struct ip_mreq mreq;
|
||||||
mreq.imr_multiaddr = address->resolved.udp_addr->multicast_ip ();
|
mreq.imr_multiaddr = address->resolved.udp_addr->multicast_ip ();
|
||||||
mreq.imr_interface = address->resolved.udp_addr->interface_ip ();
|
mreq.imr_interface = address->resolved.udp_addr->interface_ip ();
|
||||||
int rc = setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*) &mreq, sizeof (mreq));
|
rc = setsockopt (fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char*) &mreq, sizeof (mreq));
|
||||||
#ifdef ZMQ_HAVE_WINDOWS
|
#ifdef ZMQ_HAVE_WINDOWS
|
||||||
wsa_assert (rc != SOCKET_ERROR);
|
wsa_assert (rc != SOCKET_ERROR);
|
||||||
#else
|
#else
|
||||||
|
@ -173,7 +173,8 @@ int zmq::xpub_t::xsetsockopt (int option_, const void *optval_,
|
|||||||
welcome_msg.close();
|
welcome_msg.close();
|
||||||
|
|
||||||
if (optvallen_ > 0) {
|
if (optvallen_ > 0) {
|
||||||
welcome_msg.init_size(optvallen_);
|
int rc = welcome_msg.init_size(optvallen_);
|
||||||
|
errno_assert(rc == 0);
|
||||||
|
|
||||||
unsigned char *data = (unsigned char*)welcome_msg.data();
|
unsigned char *data = (unsigned char*)welcome_msg.data();
|
||||||
memcpy(data, optval_, optvallen_);
|
memcpy(data, optval_, optvallen_);
|
||||||
|
@ -925,12 +925,9 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
|||||||
// file descriptors.
|
// file descriptors.
|
||||||
zmq_assert (nitems_ <= FD_SETSIZE);
|
zmq_assert (nitems_ <= FD_SETSIZE);
|
||||||
|
|
||||||
fd_set pollset_in;
|
fd_set pollset_in = { 0 };
|
||||||
FD_ZERO (&pollset_in);
|
fd_set pollset_out = { 0 };
|
||||||
fd_set pollset_out;
|
fd_set pollset_err = { 0 };
|
||||||
FD_ZERO (&pollset_out);
|
|
||||||
fd_set pollset_err;
|
|
||||||
FD_ZERO (&pollset_err);
|
|
||||||
|
|
||||||
zmq::fd_t maxfd = 0;
|
zmq::fd_t maxfd = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user