mirror of
https://github.com/ceph/ceph
synced 2025-01-02 00:52:22 +00:00
use simplifed messenger constructor for clients
This is all mechanical except the calculation of the nonce, which is now always randomized for clients. Fixes: #13032 Signed-off-by: Josh Durgin <jdurgin@redhat.com>
This commit is contained in:
parent
e3785b0b5f
commit
a3a8c85b79
@ -172,9 +172,7 @@ int main(int argc, const char **argv, const char *envp[]) {
|
||||
goto out_mc_start_failed;
|
||||
|
||||
// start up network
|
||||
messenger = Messenger::create(g_ceph_context, g_conf->ms_type,
|
||||
entity_name_t::CLIENT(), "client",
|
||||
getpid());
|
||||
messenger = Messenger::create_client_messenger(g_ceph_context, "client");
|
||||
messenger->set_default_policy(Messenger::Policy::lossy_client(0, 0));
|
||||
messenger->set_policy(entity_name_t::TYPE_MDS,
|
||||
Messenger::Policy::lossless_client(0, 0));
|
||||
|
@ -65,10 +65,8 @@ int main(int argc, const char **argv, char *envp[])
|
||||
|
||||
cout << "ceph-syn: starting " << g_conf->num_client << " syn client(s)" << std::endl;
|
||||
for (int i=0; i<g_conf->num_client; i++) {
|
||||
messengers[i] = Messenger::create(
|
||||
g_ceph_context, g_conf->ms_type,
|
||||
entity_name_t(entity_name_t::TYPE_CLIENT,-1), "synclient",
|
||||
i * 1000000 + getpid());
|
||||
messengers[i] = Messenger::create_client_messenger(g_ceph_context,
|
||||
"synclient");
|
||||
messengers[i]->bind(g_conf->public_addr);
|
||||
mclients[i] = new MonClient(g_ceph_context);
|
||||
mclients[i]->build_initial_monmap();
|
||||
|
@ -34,9 +34,8 @@
|
||||
struct ceph_mount_info
|
||||
{
|
||||
public:
|
||||
ceph_mount_info(uint64_t msgr_nonce_, CephContext *cct_)
|
||||
: msgr_nonce(msgr_nonce_),
|
||||
mounted(false),
|
||||
ceph_mount_info(CephContext *cct_)
|
||||
: mounted(false),
|
||||
inited(false),
|
||||
client(NULL),
|
||||
monclient(NULL),
|
||||
@ -77,7 +76,7 @@ public:
|
||||
goto fail;
|
||||
|
||||
//network connection
|
||||
messenger = Messenger::create(cct, cct->_conf->ms_type, entity_name_t::CLIENT(), "client", msgr_nonce);
|
||||
messenger = Messenger::create_client_messenger(cct, "client");
|
||||
|
||||
//at last the client
|
||||
ret = -CEPHFS_ERROR_NEW_CLIENT; //defined in libcephfs.h;
|
||||
@ -235,7 +234,6 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t msgr_nonce;
|
||||
bool mounted;
|
||||
bool inited;
|
||||
Client *client;
|
||||
@ -290,14 +288,7 @@ extern "C" const char *ceph_version(int *pmajor, int *pminor, int *ppatch)
|
||||
|
||||
extern "C" int ceph_create_with_context(struct ceph_mount_info **cmount, CephContext *cct)
|
||||
{
|
||||
uint64_t nonce = 0;
|
||||
|
||||
// 6 bytes of random and 2 bytes of pid
|
||||
get_random_bytes((char*)&nonce, sizeof(nonce));
|
||||
nonce &= ~0xffff;
|
||||
nonce |= (uint64_t)getpid();
|
||||
|
||||
*cmount = new struct ceph_mount_info(nonce, cct);
|
||||
*cmount = new struct ceph_mount_info(cct);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,6 @@
|
||||
#undef dout_prefix
|
||||
#define dout_prefix *_dout << "librados: "
|
||||
|
||||
static atomic_t rados_instance;
|
||||
|
||||
bool librados::RadosClient::ms_get_authorizer(int dest_type,
|
||||
AuthAuthorizer **authorizer,
|
||||
bool force_new) {
|
||||
@ -191,7 +189,6 @@ int librados::RadosClient::connect()
|
||||
common_init_finish(cct);
|
||||
|
||||
int err;
|
||||
uint64_t nonce;
|
||||
|
||||
// already connected?
|
||||
if (state == CONNECTING)
|
||||
@ -206,9 +203,7 @@ int librados::RadosClient::connect()
|
||||
goto out;
|
||||
|
||||
err = -ENOMEM;
|
||||
nonce = getpid() + (1000000 * (uint64_t)rados_instance.inc());
|
||||
messenger = Messenger::create(cct, cct->_conf->ms_type, entity_name_t::CLIENT(-1),
|
||||
"radosclient", nonce);
|
||||
messenger = Messenger::create_client_messenger(cct, "radosclient");
|
||||
if (!messenger)
|
||||
goto out;
|
||||
|
||||
|
@ -116,9 +116,7 @@ int MonClient::get_monmap_privately()
|
||||
bool temp_msgr = false;
|
||||
Messenger* smessenger = NULL;
|
||||
if (!messenger) {
|
||||
messenger = smessenger = Messenger::create(cct, cct->_conf->ms_type,
|
||||
entity_name_t::CLIENT(-1),
|
||||
"temp_mon_client", getpid());
|
||||
messenger = smessenger = Messenger::create_client_messenger(cct, "temp_mon_client");
|
||||
messenger->add_dispatcher_head(this);
|
||||
smessenger->start();
|
||||
temp_msgr = true;
|
||||
@ -225,9 +223,7 @@ int MonClient::ping_monitor(const string &mon_id, string *result_reply)
|
||||
|
||||
MonClientPinger *pinger = new MonClientPinger(cct, result_reply);
|
||||
|
||||
Messenger *smsgr = Messenger::create(cct, cct->_conf->ms_type,
|
||||
entity_name_t::CLIENT(-1),
|
||||
"temp_ping_client", getpid());
|
||||
Messenger *smsgr = Messenger::create_client_messenger(cct, "temp_ping_client");
|
||||
smsgr->add_dispatcher_head(pinger);
|
||||
smsgr->start();
|
||||
|
||||
|
@ -244,8 +244,7 @@ class ClientStub : public TestStub
|
||||
return err;
|
||||
}
|
||||
|
||||
messenger.reset(Messenger::create(cct, cct->_conf->ms_type, entity_name_t::CLIENT(-1),
|
||||
"stubclient", getpid()));
|
||||
messenger.reset(Messenger::create_client_messenger(cct, "stubclient"));
|
||||
assert(messenger.get() != NULL);
|
||||
|
||||
messenger->set_default_policy(
|
||||
|
@ -26,7 +26,7 @@ MDSUtility::MDSUtility() :
|
||||
waiting_for_mds_map(NULL)
|
||||
{
|
||||
monc = new MonClient(g_ceph_context);
|
||||
messenger = Messenger::create(g_ceph_context, g_ceph_context->_conf->ms_type, entity_name_t::CLIENT(), "mds", getpid());
|
||||
messenger = Messenger::create_client_messenger(g_ceph_context, "mds");
|
||||
mdsmap = new MDSMap();
|
||||
objecter = new Objecter(g_ceph_context, messenger, monc, NULL, 0, 0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user