Unverified Commit 2e849a4d authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #2913 from ZMQers/add-const

Problem: several fields are non-const without need
parents 9872daa2 368eff9e
......@@ -56,7 +56,7 @@ struct address_t
const std::string protocol;
const std::string address;
ctx_t *parent;
ctx_t *const parent;
// Protocol specific resolved address
union
......
......@@ -122,7 +122,7 @@ class shared_message_memory_allocator
private:
unsigned char *buf;
std::size_t bufsize;
std::size_t max_size;
const std::size_t max_size;
zmq::msg_t::content_t *msg_content;
std::size_t maxCounters;
};
......
......@@ -60,9 +60,9 @@ template <typename T> class encoder_base_t : public i_encoder
next (NULL),
new_msg_flag (false),
bufsize (bufsize_),
buf ((unsigned char *) malloc (bufsize_)),
in_progress (NULL)
{
buf = (unsigned char *) malloc (bufsize_);
alloc_assert (buf);
}
......@@ -166,8 +166,8 @@ template <typename T> class encoder_base_t : public i_encoder
bool new_msg_flag;
// The buffer for encoded data.
size_t bufsize;
unsigned char *buf;
const size_t bufsize;
unsigned char *const buf;
encoder_base_t (const encoder_base_t &);
void operator= (const encoder_base_t &);
......
......@@ -77,7 +77,7 @@ class mailbox_safe_t : public i_mailbox
condition_variable_t cond_var;
// Synchronize access to the mailbox from receivers and senders
mutex_t *sync;
mutex_t *const sync;
std::vector<zmq::signaler_t *> signalers;
......
......@@ -128,7 +128,7 @@ class mechanism_t
// Properties received from ZAP server.
metadata_t::dict_t zap_properties;
options_t options;
const options_t options;
private:
blob_t routing_id;
......
......@@ -62,7 +62,7 @@ class metadata_t
atomic_counter_t ref_cnt;
// Dictionary holding metadata.
dict_t dict;
const dict_t dict;
};
}
......
......@@ -134,7 +134,7 @@ class object_t
private:
// Context provides access to the global state.
zmq::ctx_t *ctx;
zmq::ctx_t *const ctx;
// Thread ID of the thread the object belongs to.
uint32_t tid;
......
......@@ -670,9 +670,9 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
*w_ = *r_ = -1;
return -1;
} else {
// If there's no SOCK_CLOEXEC, let's try the second best option. Note that
// race condition can cause socket not to be closed (if fork happens
// between socket creation and this point).
// If there's no SOCK_CLOEXEC, let's try the second best option. Note that
// race condition can cause socket not to be closed (if fork happens
// between socket creation and this point).
#if !defined ZMQ_HAVE_SOCK_CLOEXEC && defined FD_CLOEXEC
rc = fcntl (sv[0], F_SETFD, FD_CLOEXEC);
errno_assert (rc != -1);
......
......@@ -285,7 +285,7 @@ class socket_base_t : public own_t,
std::string last_endpoint;
// Indicate if the socket is thread safe
bool thread_safe;
const bool thread_safe;
// Signaler to be used in the reaping stage
signaler_t *reaper_signaler;
......
......@@ -178,7 +178,7 @@ class stream_engine_t : public io_object_t, public i_engine
// The session this engine is attached to.
zmq::session_base_t *session;
options_t options;
const options_t options;
// String representation of endpoint
std::string endpoint;
......
......@@ -72,12 +72,15 @@ zmq::tcp_connecter_t::tcp_connecter_t (class io_thread_t *io_thread_,
connect_timer_started (false),
reconnect_timer_started (false),
session (session_),
current_reconnect_ivl (options.reconnect_ivl)
current_reconnect_ivl (options.reconnect_ivl),
socket (session->get_socket ())
{
zmq_assert (addr);
zmq_assert (addr->protocol == "tcp");
addr->to_string (endpoint);
socket = session->get_socket ();
// TODO the return value is unused! what if it fails? if this is impossible
// or does not matter, change such that endpoint in initialized using an
// initializer, and make endpoint const
}
zmq::tcp_connecter_t::~tcp_connecter_t ()
......
......@@ -97,7 +97,7 @@ class tcp_connecter_t : public own_t, public io_object_t
fd_t connect ();
// Address to connect to. Owned by session_base_t.
address_t *addr;
address_t *const addr;
// Underlying socket.
fd_t s;
......@@ -117,7 +117,7 @@ class tcp_connecter_t : public own_t, public io_object_t
bool reconnect_timer_started;
// Reference to the session we belong to.
zmq::session_base_t *session;
zmq::session_base_t *const session;
// Current reconnect ivl, updated for backoff strategy
int current_reconnect_ivl;
......@@ -126,7 +126,7 @@ class tcp_connecter_t : public own_t, public io_object_t
std::string endpoint;
// Socket
zmq::socket_base_t *socket;
zmq::socket_base_t *const socket;
tcp_connecter_t (const tcp_connecter_t &);
const tcp_connecter_t &operator= (const tcp_connecter_t &);
......
......@@ -54,7 +54,7 @@ class v1_decoder_t : public zmq::c_single_allocator,
unsigned char tmpbuf[8];
msg_t in_progress;
int64_t maxmsgsize;
const int64_t maxmsgsize;
v1_decoder_t (const v1_decoder_t &);
void operator= (const v1_decoder_t &);
......
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