#ifndef CEPH_SIMPLEMESSENGER_H
#define CEPH_SIMPLEMESSENGER_H
+#include <list>
+#include <map>
+
#include "include/types.h"
#include "include/xlist.h"
-#include <list>
-#include <map>
-using namespace std;
#include "include/unordered_map.h"
#include "include/unordered_set.h"
#include "common/Mutex.h"
-#include "include/Spinlock.h"
#include "common/Cond.h"
#include "common/Thread.h"
#include "common/Throttle.h"
+#include "include/spinlock.h"
+
#include "msg/SimplePolicyMessenger.h"
#include "msg/Message.h"
-#include "include/assert.h"
+#include "include/ceph_assert.h"
#include "msg/DispatchQueue.h"
#include "Pipe.h"
/** @defgroup Accessors
* @{
*/
- void set_addr_unknowns(const entity_addr_t& addr) override;
- void set_addr(const entity_addr_t &addr) override;
+ bool set_addr_unknowns(const entity_addrvec_t& addr) override;
+ void set_addrs(const entity_addrvec_t &addr) override;
+ void set_myaddrs(const entity_addrvec_t& a) override;
int get_dispatch_queue_len() override {
return dispatch_queue.get_queue_len();
* @{
*/
void set_cluster_protocol(int p) override {
- assert(!started && !did_bind);
+ ceph_assert(!started && !did_bind);
cluster_protocol = p;
}
* @defgroup Messaging
* @{
*/
- int send_message(Message *m, const entity_inst_t& dest) override {
- return _send_message(m, dest);
+ int send_to(
+ Message *m,
+ int type,
+ const entity_addrvec_t& addr) override {
+ // temporary
+ return _send_message(m, entity_inst_t(entity_name_t(type, -1),
+ addr.legacy_addr()));
}
int send_message(Message *m, Connection *con) {
* @defgroup Connection Management
* @{
*/
- ConnectionRef get_connection(const entity_inst_t& dest) override;
+ ConnectionRef connect_to(int type, const entity_addrvec_t& addrs) override;
ConnectionRef get_loopback_connection() override;
int send_keepalive(Connection *con);
void mark_down(const entity_addr_t& addr) override;
/// counter for the global seq our connection protocol uses
__u32 global_seq;
/// lock to protect the global_seq
- ceph_spinlock_t global_seq_lock;
+ ceph::spinlock global_seq_lock;
+
+ entity_addr_t my_addr;
/**
* hash map of addresses to Pipes
*/
ceph::unordered_map<entity_addr_t, Pipe*> rank_pipe;
/**
- * list of pipes are in teh process of accepting
+ * list of pipes are in the process of accepting
*
* These are not yet in the rank_pipe map.
*/
* @{
*/
- /**
- * This wraps ms_deliver_get_authorizer. We use it for Pipe.
- */
- AuthAuthorizer *get_authorizer(int peer_type, bool force_new);
- /**
- * This wraps ms_deliver_verify_authorizer; we use it for Pipe.
- */
- bool verify_authorizer(Connection *con, int peer_type, int protocol, bufferlist& auth,
- bufferlist& auth_reply,
- bool& isvalid,CryptoKey& session_key,
- std::unique_ptr<AuthAuthorizerChallenge> *challenge);
/**
* Increment the global sequence for this SimpleMessenger and return it.
* This is for the connect protocol, although it doesn't hurt if somebody
* @return a global sequence ID that nobody else has seen.
*/
__u32 get_global_seq(__u32 old=0) {
- ceph_spin_lock(&global_seq_lock);
+ std::lock_guard<decltype(global_seq_lock)> lg(global_seq_lock);
+
if (old > global_seq)
global_seq = old;
__u32 ret = ++global_seq;
- ceph_spin_unlock(&global_seq_lock);
+
return ret;
}
/**