]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: services: assert on unexpected op request type
authorJoao Eduardo Luis <joao@suse.de>
Fri, 26 Jun 2015 09:29:04 +0000 (10:29 +0100)
committerJoao Eduardo Luis <joao@suse.de>
Thu, 16 Jul 2015 17:31:23 +0000 (18:31 +0100)
Ensures some type safety by asserting on the request type.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/mon/Elector.cc
src/mon/Monitor.cc
src/mon/Paxos.cc
src/mon/PaxosService.cc

index 754e247928cb6e20376123012d939df4d010f62c..5b1ef4e207a0fc891f1c18e10cdeb8ff4fc52b96 100644 (file)
@@ -393,6 +393,8 @@ void Elector::handle_nak(MonOpRequestRef op)
 void Elector::dispatch(MonOpRequestRef op)
 {
   op->mark_event("elector:dispatch");
+  assert(op->is_type_election());
+
   switch (op->get_req()->get_type()) {
     
   case MSG_MON_ELECTION:
index 0d68a2cd5297a43ef800405158230f2622a7d599..2dd320aef9b1f0a8b93fbb750baafbc87df28716 100644 (file)
@@ -2551,6 +2551,7 @@ bool Monitor::is_keyring_required()
 
 void Monitor::handle_command(MonOpRequestRef op)
 {
+  assert(op->is_type_command());
   MMonCommand *m = static_cast<MMonCommand*>(op->get_req());
   if (m->fsid != monmap->fsid) {
     dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid << dendl;
index 3f3280d54f577c4b3bc783af18f37df141b7e3b6..44b8184aec0d88625872720cc018c48125aca9b1 100644 (file)
@@ -1368,6 +1368,7 @@ void Paxos::restart()
 
 void Paxos::dispatch(MonOpRequestRef op)
 {
+  assert(op->is_type_paxos());
   op->mark_paxos_event("dispatch");
   PaxosServiceMessage *m = static_cast<PaxosServiceMessage*>(op->get_req());
   // election in progress?
index 84d63cf2a4c60ed447075521e64976e667cedb36..030af78683151be232bec8a78f1e2901a85285dd 100644 (file)
@@ -36,6 +36,7 @@ static ostream& _prefix(std::ostream *_dout, Monitor *mon, Paxos *paxos, string
 
 bool PaxosService::dispatch(MonOpRequestRef op)
 {
+  assert(op->is_type_service() || op->is_type_command());
   PaxosServiceMessage *m = static_cast<PaxosServiceMessage*>(op->get_req());
   op->mark_event("psvc:dispatch");