diff --git a/src/common/LogClient.cc b/src/common/LogClient.cc index 73214f7d137..8279dc41911 100644 --- a/src/common/LogClient.cc +++ b/src/common/LogClient.cc @@ -82,4 +82,16 @@ void LogClient::handle_log(MLog *m) delete m; } +bool LogClient::dispatch_impl(Message *m) +{ + dout(20) << "dispatch " << m << dendl; + + switch (m->get_type()) { + case MSG_LOG: + handle_log((MLog*)m); + return true; + } + return false; +} + diff --git a/src/common/LogClient.h b/src/common/LogClient.h index d5f49147b6b..fec14908e2f 100644 --- a/src/common/LogClient.h +++ b/src/common/LogClient.h @@ -27,9 +27,11 @@ class MLog; class MonMap; -class LogClient { +class LogClient : public Dispatcher { Messenger *messenger; MonMap *monmap; + + bool dispatch_impl(Message *m); public: // -- log -- @@ -42,8 +44,11 @@ class LogClient { void send_log(); void handle_log(MLog *m); - LogClient(Messenger *m, MonMap *mm) : messenger(m), monmap(mm), - log_lock("LogClient::log_lock"), last_log(0) {} + LogClient(Messenger *m, MonMap *mm, Dispatcher *disp) : messenger(m), monmap(mm), + log_lock("LogClient::log_lock"), last_log(0) { + if (disp) + disp->link_dispatcher(this); + } }; #endif diff --git a/src/msg/Dispatcher.h b/src/msg/Dispatcher.h index 42ce2e7d8ae..c8274f30a9c 100644 --- a/src/msg/Dispatcher.h +++ b/src/msg/Dispatcher.h @@ -30,20 +30,22 @@ class Dispatcher { Dispatcher() : next(NULL) { } virtual void dispatch(Message *m) { - if (!dispatch_impl(m)) { - if (next) { - next->dispatch(m); - } else { + bool ret = false; + if (next) + ret = next->dispatch_impl(m); + + if (!ret) { + if (!dispatch_impl(m)) { assert(0); } } } - virtual void add(Dispatcher *disp) { + virtual void link_dispatcher(Dispatcher *disp) { if (!next) { next = disp; } else { - next->add(disp); + next->link_dispatcher(disp); } } diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index a3acdece834..c77b8fa72d1 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -378,7 +378,7 @@ int OSD::init() assert(whoami == superblock.whoami); // log - logclient = new LogClient(messenger, monmap); + logclient = new LogClient(messenger, monmap, this); char name[80]; sprintf(name, "osd%d", whoami); logger = new Logger(name, (LogType*)&osd_logtype); @@ -1466,10 +1466,6 @@ bool OSD::dispatch_impl(Message *m) delete m; break; - case MSG_LOG: - logclient->handle_log((MLog*)m); - break; - // -- don't need OSDMap -- // map and replication