Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / messenger / xio_dispatcher.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2013 CohortFS, LLC
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15 #include "xio_dispatcher.h"
16 #include "messages/MPing.h"
17 #include "messages/MDataPing.h"
18
19 XioDispatcher::XioDispatcher(Messenger *msgr) :
20   Dispatcher(msgr->cct),
21   active(false),
22   messenger(msgr),
23   dcount(0)
24 {
25   // nothing
26 }
27
28 XioDispatcher::~XioDispatcher() {
29   // nothing
30 }
31
32 bool XioDispatcher::ms_dispatch(Message *m)
33 {
34   ConnectionRef conn;
35   uint64_t dc = 0;
36
37   dc = dcount++;
38
39   switch (m->get_type()) {
40   case CEPH_MSG_PING:
41     break;
42   case MSG_DATA_PING:
43   {
44     MDataPing* mdp __attribute__((unused)) = static_cast<MDataPing*>(m);
45     //cout << "MDataPing " << mdp->tag << " " << mdp->counter << std::endl;
46     //mdp->get_data().hexdump(cout);
47   }
48     break;
49   default:
50     abort();
51   }
52
53   if (unlikely(m->get_magic() & MSG_MAGIC_TRACE_CTR)) {
54     if (unlikely(dc % 65536) == 0) {
55       struct timespec ts;
56       clock_gettime(CLOCK_REALTIME_COARSE, &ts);
57       std::cout << "ping " << dc << " nanos: " <<
58         ts.tv_nsec + (ts.tv_sec * 1000000000)  << std::endl;
59     }
60   } /* trace ctr */
61
62   m->put();
63
64   return true;
65 }
66
67 bool XioDispatcher::ms_handle_reset(Connection *con)
68 {
69   return true;
70 }
71
72 void XioDispatcher::ms_handle_remote_reset(Connection *con)
73 {
74   // nothing
75 }
76