diff --git a/src/auth/cephx/CephxSessionHandler.cc b/src/auth/cephx/CephxSessionHandler.cc index b2d402d2af3..defc4edda37 100644 --- a/src/auth/cephx/CephxSessionHandler.cc +++ b/src/auth/cephx/CephxSessionHandler.cc @@ -31,7 +31,7 @@ int CephxSessionHandler::sign_message(Message *m) return 0; } bufferlist bl_plaintext, bl_encrypted; - ceph_msg_header header = m->get_header(); + const ceph_msg_header& header = m->get_header(); std::string error; ceph_msg_footer& en_footer = m->get_footer(); @@ -77,8 +77,8 @@ int CephxSessionHandler::check_message_signature(Message *m) bufferlist bl_plaintext, bl_ciphertext; std::string sig_error; - ceph_msg_header& header = m->get_header(); - ceph_msg_footer& footer = m->get_footer(); + const ceph_msg_header& header = m->get_header(); + const ceph_msg_footer& footer = m->get_footer(); if ((features & CEPH_FEATURE_MSG_AUTH) == 0) { // it's fine, we didn't negotiate this feature. diff --git a/src/common/HeartbeatMap.cc b/src/common/HeartbeatMap.cc index 9787f737cef..2c58276196a 100644 --- a/src/common/HeartbeatMap.cc +++ b/src/common/HeartbeatMap.cc @@ -41,7 +41,7 @@ HeartbeatMap::~HeartbeatMap() assert(m_workers.empty()); } -heartbeat_handle_d *HeartbeatMap::add_worker(string name) +heartbeat_handle_d *HeartbeatMap::add_worker(const string& name) { m_rwlock.get_write(); ldout(m_cct, 10) << "add_worker '" << name << "'" << dendl; @@ -52,7 +52,7 @@ heartbeat_handle_d *HeartbeatMap::add_worker(string name) return h; } -void HeartbeatMap::remove_worker(heartbeat_handle_d *h) +void HeartbeatMap::remove_worker(const heartbeat_handle_d *h) { m_rwlock.get_write(); ldout(m_cct, 10) << "remove_worker '" << h->name << "'" << dendl; @@ -61,7 +61,7 @@ void HeartbeatMap::remove_worker(heartbeat_handle_d *h) delete h; } -bool HeartbeatMap::_check(heartbeat_handle_d *h, const char *who, time_t now) +bool HeartbeatMap::_check(const heartbeat_handle_d *h, const char *who, time_t now) { bool healthy = true; time_t was; diff --git a/src/common/HeartbeatMap.h b/src/common/HeartbeatMap.h index a4aee48a191..5513e186c2a 100644 --- a/src/common/HeartbeatMap.h +++ b/src/common/HeartbeatMap.h @@ -41,7 +41,7 @@ namespace ceph { */ struct heartbeat_handle_d { - std::string name; + const std::string name; atomic_t timeout, suicide_timeout; time_t grace, suicide_grace; std::list::iterator list_item; @@ -54,8 +54,8 @@ struct heartbeat_handle_d { class HeartbeatMap { public: // register/unregister - heartbeat_handle_d *add_worker(std::string name); - void remove_worker(heartbeat_handle_d *h); + heartbeat_handle_d *add_worker(const std::string& name); + void remove_worker(const heartbeat_handle_d *h); // reset the timeout so that it expects another touch within grace amount of time void reset_timeout(heartbeat_handle_d *h, time_t grace, time_t suicide_grace); @@ -77,7 +77,7 @@ class HeartbeatMap { time_t m_inject_unhealthy_until; std::list m_workers; - bool _check(heartbeat_handle_d *h, const char *who, time_t now); + bool _check(const heartbeat_handle_d *h, const char *who, time_t now); }; } diff --git a/src/common/RefCountedObj.h b/src/common/RefCountedObj.h index 729bbb9fd4b..3755018f801 100644 --- a/src/common/RefCountedObj.h +++ b/src/common/RefCountedObj.h @@ -52,7 +52,7 @@ public: cct = c; } - uint64_t get_nref() { + uint64_t get_nref() const { return nref.read(); } }; diff --git a/src/librados/ListObjectImpl.h b/src/librados/ListObjectImpl.h index fdbe509d154..fe52f68075a 100644 --- a/src/librados/ListObjectImpl.h +++ b/src/librados/ListObjectImpl.h @@ -28,9 +28,9 @@ struct ListObjectImpl { ListObjectImpl(std::string n, std::string o, std::string l): nspace(n), oid(o), locator(l) {} - const std::string& get_nspace() { return nspace; } - const std::string& get_oid() { return oid; } - const std::string& get_locator() { return locator; } + const std::string& get_nspace() const { return nspace; } + const std::string& get_oid() const { return oid; } + const std::string& get_locator() const { return locator; } }; WRITE_EQ_OPERATORS_3(ListObjectImpl, nspace, oid, locator) WRITE_CMP_OPERATORS_3(ListObjectImpl, nspace, oid, locator) diff --git a/src/msg/Message.h b/src/msg/Message.h index c2cd1238150..ddba0e57a89 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -313,15 +313,17 @@ public: Throttle *get_message_throttler() { return msg_throttler; } void set_dispatch_throttle_size(uint64_t s) { dispatch_throttle_size = s; } - uint64_t get_dispatch_throttle_size() { return dispatch_throttle_size; } + uint64_t get_dispatch_throttle_size() const { return dispatch_throttle_size; } + const ceph_msg_header &get_header() const { return header; } ceph_msg_header &get_header() { return header; } void set_header(const ceph_msg_header &e) { header = e; } void set_footer(const ceph_msg_footer &e) { footer = e; } + const ceph_msg_footer &get_footer() const { return footer; } ceph_msg_footer &get_footer() { return footer; } void set_src(const entity_name_t& src) { header.src = src; } - uint32_t get_magic() { return magic; } + uint32_t get_magic() const { return magic; } void set_magic(int _magic) { magic = _magic; } /* @@ -346,7 +348,7 @@ public: clear_buffers(); // let subclass drop buffers as well } - bool empty_payload() { return payload.length() == 0; } + bool empty_payload() const { return payload.length() == 0; } bufferlist& get_payload() { return payload; } void set_payload(bufferlist& bl) { if (byte_throttler) diff --git a/src/msg/async/AsyncConnection.cc b/src/msg/async/AsyncConnection.cc index a0deea1f2d4..0efb11107e7 100644 --- a/src/msg/async/AsyncConnection.cc +++ b/src/msg/async/AsyncConnection.cc @@ -2174,7 +2174,7 @@ int AsyncConnection::_send(Message *m) return rc; } -int AsyncConnection::write_message(ceph_msg_header& header, ceph_msg_footer& footer, +int AsyncConnection::write_message(const ceph_msg_header& header, const ceph_msg_footer& footer, bufferlist& blist) { bufferlist bl; diff --git a/src/msg/async/AsyncConnection.h b/src/msg/async/AsyncConnection.h index da2aad1e4f4..91c1d6581ac 100644 --- a/src/msg/async/AsyncConnection.h +++ b/src/msg/async/AsyncConnection.h @@ -63,7 +63,7 @@ class AsyncConnection : public Connection { int randomize_out_seq(); void handle_ack(uint64_t seq); void _send_keepalive_or_ack(bool ack=false, utime_t *t=NULL); - int write_message(ceph_msg_header& header, ceph_msg_footer& footer, bufferlist& blist); + int write_message(const ceph_msg_header& header, const ceph_msg_footer& footer, bufferlist& blist); int _reply_accept(char tag, ceph_msg_connect &connect, ceph_msg_connect_reply &reply, bufferlist authorizer_reply) { bufferlist reply_bl; @@ -203,7 +203,6 @@ class AsyncConnection : public Connection { return statenames[state]; } - CephContext *cc; AsyncMessenger *async_msgr; int global_seq; __u32 connect_seq, peer_global_seq; diff --git a/src/msg/simple/Pipe.cc b/src/msg/simple/Pipe.cc index 74f2c876218..7ebb6297b45 100644 --- a/src/msg/simple/Pipe.cc +++ b/src/msg/simple/Pipe.cc @@ -1798,8 +1798,8 @@ void Pipe::writer() m->encode(features, msgr->crcflags); // prepare everything - ceph_msg_header& header = m->get_header(); - ceph_msg_footer& footer = m->get_footer(); + const ceph_msg_header& header = m->get_header(); + const ceph_msg_footer& footer = m->get_footer(); // Now that we have all the crcs calculated, handle the // digital signature for the message, if the pipe has session @@ -2237,7 +2237,7 @@ int Pipe::write_keepalive2(char tag, const utime_t& t) } -int Pipe::write_message(ceph_msg_header& header, ceph_msg_footer& footer, bufferlist& blist) +int Pipe::write_message(const ceph_msg_header& header, const ceph_msg_footer& footer, bufferlist& blist) { int ret; diff --git a/src/msg/simple/Pipe.h b/src/msg/simple/Pipe.h index 9b464a5065b..ddfa99f78af 100644 --- a/src/msg/simple/Pipe.h +++ b/src/msg/simple/Pipe.h @@ -230,7 +230,7 @@ class DispatchQueue; int read_message(Message **pm, AuthSessionHandler *session_security_copy); - int write_message(ceph_msg_header& h, ceph_msg_footer& f, bufferlist& body); + int write_message(const ceph_msg_header& h, const ceph_msg_footer& f, bufferlist& body); /** * Write the given data (of length len) to the Pipe's socket. This function * will loop until all passed data has been written out.