Skip to content

Commit

Permalink
msgr: remove refcounting of Messengers.
Browse files Browse the repository at this point in the history
This was pretty pointless since each Messenger has a well-defined
exit point and shutdown process.

Signed-off-by: Greg Farnum <[email protected]>
  • Loading branch information
gregsfortytwo committed Mar 2, 2012
1 parent 091b176 commit 38bec5d
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/ceph_mon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ int main(int argc, const char **argv)

store.umount();
delete mon;
messenger->destroy();
delete messenger;

// cd on exit, so that gmon.out (if any) goes into a separate directory for each node.
char s[20];
Expand Down
8 changes: 4 additions & 4 deletions src/ceph_osd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,10 @@ int main(int argc, const char **argv)

// done
delete osd;
client_messenger->destroy();
messenger_hbin->destroy();
messenger_hbout->destroy();
cluster_messenger->destroy();
delete client_messenger;
delete messenger_hbin;
delete messenger_hbout;
delete cluster_messenger;

// cd on exit, so that gmon.out (if any) goes into a separate directory for each node.
char s[20];
Expand Down
2 changes: 1 addition & 1 deletion src/ceph_syn.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int main(int argc, const char **argv, char *envp[])
// wait for messenger to finish
delete mclients[i];
messengers[i]->wait();
messengers[i]->destroy();
delete messengers[i];
}
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libcephfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ceph_mount_info
}
if (messenger) {
messenger->wait();
messenger->destroy();
delete messenger;
messenger = NULL;
}
if (monclient) {
Expand Down
2 changes: 1 addition & 1 deletion src/librados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ void librados::RadosClient::shutdown()
librados::RadosClient::~RadosClient()
{
if (messenger)
messenger->destroy();
delete messenger;
if (objecter)
delete objecter;
common_destroy_context(cct);
Expand Down
2 changes: 1 addition & 1 deletion src/mds/MDS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ MDS::~MDS() {
}

if (messenger)
messenger->destroy();
delete messenger;
}

void MDS::create_logger()
Expand Down
2 changes: 1 addition & 1 deletion src/mon/MonClient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ int MonClient::get_monmap_privately()
messenger->shutdown();
if (smessenger)
smessenger->wait();
messenger->destroy();
delete messenger;
messenger = 0;
monc_lock.Lock();
}
Expand Down
19 changes: 2 additions & 17 deletions src/msg/Messenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,17 @@ class Messenger {
/// set to true once the Messenger has started, and set to false on shutdown
bool started;

atomic_t nref;

public:
CephContext *cct;
Messenger(CephContext *cct_, entity_name_t w)
: default_send_priority(CEPH_MSG_PRIO_DEFAULT), started(false),
nref(1), cct(cct_)
cct(cct_)
{
_my_name = w;
}
virtual ~Messenger() {}

void get() {
nref.inc();
}
void put() {
if (nref.dec() == 0)
delete this;
}
virtual void destroy() {
put();
}

// accessors
Expand Down Expand Up @@ -263,12 +254,6 @@ class Messenger {
virtual Connection *get_connection(const entity_inst_t& dest) = 0;

virtual int rebind(int avoid_port) { return -EOPNOTSUPP; }

protected:
//destruction should be handled via destroy()
virtual ~Messenger() {
assert(nref.read() == 0);
}
};


Expand Down
6 changes: 1 addition & 5 deletions src/msg/SimpleMessenger.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,9 +476,7 @@ class SimpleMessenger : public Messenger {
public:
ReaperThread(SimpleMessenger *m) : msgr(m) {}
void *entry() {
msgr->get();
msgr->reaper_entry();
msgr->put();
return 0;
}
} reaper_thread;
Expand Down Expand Up @@ -519,9 +517,7 @@ class SimpleMessenger : public Messenger {
public:
DispatchThread(SimpleMessenger *_messenger) : msgr(_messenger) {}
void *entry() {
msgr->get();
msgr->dispatch_entry();
msgr->put();
return 0;
}
} dispatch_thread;
Expand Down Expand Up @@ -553,7 +549,7 @@ class SimpleMessenger : public Messenger {
dispatch_queue.local_pipe = new Pipe(this, Pipe::STATE_OPEN);
init_local_pipe();
}
~SimpleMessenger() {
virtual ~SimpleMessenger() {
delete dispatch_queue.local_pipe;
}

Expand Down
2 changes: 1 addition & 1 deletion src/tools/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ int ceph_tool_common_shutdown(CephToolCtx *ctx)
ctx->timer.shutdown();
ctx->lock.Unlock();

messenger->destroy();
delete messenger;
tok_end(tok);

return 0;
Expand Down

0 comments on commit 38bec5d

Please sign in to comment.